Skip to content

Instantly share code, notes, and snippets.

@NervosaX
Last active November 1, 2016 04:52
Show Gist options
  • Save NervosaX/030a2e77f2600e47a26afbb831b70d6d to your computer and use it in GitHub Desktop.
Save NervosaX/030a2e77f2600e47a26afbb831b70d6d to your computer and use it in GitHub Desktop.
Cerebral libdef WIP
declare type CerebralPath = string | Array<string>;
declare module 'cerebral' {
declare interface StateFunc {
set(path: CerebralPath, value: ?any): void;
get(path: CerebralPath): void;
}
declare interface OutputFuncEmptyT {
(output: ?Object): void;
}
declare type OutputFuncAsyncT = {
[key: string]: OutputFuncEmptyT
}
declare type OutputFuncT = OutputFuncEmptyT & OutputFuncAsyncT;
declare type ControllerT = {
(model: Function): ControllerT;
addState(state: Object): void;
addModules(modules: Object): void;
addContextProvider(provider: Function): void;
addServices(services: Object): void;
}
declare interface ProviderT {
state: StateFunc;
input: Object;
output: OutputFuncT;
services: Object;
}
declare module.exports: {
Controller: ControllerT
}
}
declare module 'cerebral/models/immutable' {
declare module.exports: Function;
}
declare module 'cerebral/operators' {
declare class Operators {
copy(from: string, to: string): void;
set(from: CerebralPath, to: any): void;
}
declare module.exports: Operators;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment