update store types

pull/1208/head
Rich Harris 6 years ago
parent bda2310bcf
commit 59d67f085b

14
store.d.ts vendored

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

Loading…
Cancel
Save