From 05bbc8bb835462dafab4188c8cc3e69f2f4ba49a Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 9 Sep 2015 07:31:13 +0500 Subject: [PATCH 1/2] riotcontrol: added definitions --- riotcontrol/riotcontrol.d.ts | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 riotcontrol/riotcontrol.d.ts diff --git a/riotcontrol/riotcontrol.d.ts b/riotcontrol/riotcontrol.d.ts new file mode 100644 index 000000000..0fcafcf28 --- /dev/null +++ b/riotcontrol/riotcontrol.d.ts @@ -0,0 +1,26 @@ +// Type definitions for RiotControl +// Project: https://github.com/jimsparkman/RiotControl +// Definitions by: Ilya Mochalov +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +declare module RiotControl { + interface Store { + on(events: string, fn: Function): Store; + one(name: string, fn: Function): Store; + off(events: string, fn?: Function): Store; + trigger(name: string, ...args: any[]): Store; + } + + var _stores: Store[]; + + function addStore(store: Store): void; + + function on(events: string, fn: Function): void; + function one(name: string, fn: Function): void; + function off(events: string, fn?: Function): void; + function trigger(name: string, ...args: any[]): void; +} + +declare module "riotcontrol" { + export = RiotControl; +} From 026ee4de9e4c7ef14276e77bb5f511b453302f7b Mon Sep 17 00:00:00 2001 From: Ilya Mochalov Date: Wed, 9 Sep 2015 07:31:32 +0500 Subject: [PATCH 2/2] riotcontrol: added tests --- riotcontrol/riotcontrol-tests.ts | 41 ++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 riotcontrol/riotcontrol-tests.ts diff --git a/riotcontrol/riotcontrol-tests.ts b/riotcontrol/riotcontrol-tests.ts new file mode 100644 index 000000000..b3eee8b2e --- /dev/null +++ b/riotcontrol/riotcontrol-tests.ts @@ -0,0 +1,41 @@ +/// + +import riotcontrol = require('riotcontrol'); + +{ + let store: RiotControl.Store; + let result: void; + result = riotcontrol.addStore(store); +} + +{ + let events: string; + let fn: Function; + let result: void; + result = riotcontrol.on(events, fn); +} + +{ + let name: string; + let fn: Function; + let result: void; + result = riotcontrol.one(name, fn); +} + +{ + let events: string; + let fn: Function; + let result: void; + result = riotcontrol.off(events); + result = riotcontrol.off(events, fn); +} + +{ + let name: string; + let arg: any; + let result: void; + result = riotcontrol.trigger(name); + result = riotcontrol.trigger(name, arg); + result = riotcontrol.trigger(name, arg, arg); + result = riotcontrol.trigger(name, arg, arg, arg); +}