mirror of
https://github.com/sveltejs/svelte.git
synced 2024-12-01 17:30:59 +01:00
Add TypeScript definitions for store (fixes #1207)
This commit is contained in:
parent
18d3313838
commit
e7f448d395
23
store.d.ts
vendored
Normal file
23
store.d.ts
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
interface Options {
|
||||
immutable: boolean;
|
||||
}
|
||||
|
||||
interface ObserveOptions {
|
||||
defer: boolean;
|
||||
init: boolean;
|
||||
}
|
||||
|
||||
interface Cancellable {
|
||||
cancel: () => void;
|
||||
}
|
||||
|
||||
export declare class Store<State> {
|
||||
constructor(state: State, options?: Options);
|
||||
|
||||
public compute(key: string, dependencies: string[]): 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 set(state: State);
|
||||
}
|
Loading…
Reference in New Issue
Block a user