|
|
|
@ -2,22 +2,18 @@ interface Options {
|
|
|
|
|
immutable: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface ObserveOptions {
|
|
|
|
|
defer: boolean;
|
|
|
|
|
init: boolean;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
interface Cancellable {
|
|
|
|
|
cancel: () => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export declare class Store<State> {
|
|
|
|
|
type State = Record<string, any>;
|
|
|
|
|
|
|
|
|
|
export declare class Store {
|
|
|
|
|
constructor(state: State, options?: Options);
|
|
|
|
|
|
|
|
|
|
public compute(key: string, dependencies: string[]): void;
|
|
|
|
|
public fire(name: string, data?: any): void;
|
|
|
|
|
public get(): State;
|
|
|
|
|
public get<T>(key: string): T;
|
|
|
|
|
public observe<T>(key: string, callback: (value: T) => any, options?: ObserveOptions): Cancellable;
|
|
|
|
|
public onchange(callback: (state: State) => any): Cancellable;
|
|
|
|
|
public on(name: string, callback: (data: any) => void): Cancellable;
|
|
|
|
|
public set(state: State);
|
|
|
|
|
}
|
|
|
|
|