-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterface.d.ts
More file actions
36 lines (36 loc) · 1.29 KB
/
interface.d.ts
File metadata and controls
36 lines (36 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
export declare type Subscriber<T> = (value: T) => void;
export declare type Unsubscriber = () => void;
export declare type Updater<T> = (value?: T) => T;
export declare type Invalidator<T> = (value?: T) => void;
export declare type SubscribeInvalidateTuple<T> = [Subscriber<T>, Invalidator<T>];
export declare type StartStopNotifier<T> = (set: Subscriber<T>) => Unsubscriber | void;
export interface Readable<T> {
/**
* Get value and inform subscribers.
*/
get(): T;
/**
* Subscribe on value changes.
* @param run subscription callback
* @param invalidate cleanup callback
*/
subscribe(run: Subscriber<T>, invalidate?: Invalidator<T>): Unsubscriber;
}
export interface Writable<T> extends Readable<T> {
/**
* Set value and inform subscribers.
* @param value to set
*/
set(value?: T): void;
/**
* Update value using callback and inform subscribers.
* @param updater callback
*/
update(updater: Updater<T>): void;
}
/** One or more `Readable`s. */
export declare type Stores = Readable<any> | [Readable<any>, ...Array<Readable<any>>];
/** One or more values from `Readable` stores. */
export declare type StoresValues<T> = T extends Readable<infer U> ? U : {
[K in keyof T]: T[K] extends Readable<infer U> ? U : never;
};