-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
76 lines (60 loc) · 1.7 KB
/
index.d.ts
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import Scheduler from './Scheduler';
export type LiveSetChangeRecord<T> =
| { type: 'add'; value: T }
| { type: 'remove'; value: T }
| { type: 'end' };
export interface LiveSetController<T> {
closed: boolean;
add(item: T): void;
remove(item: T): void;
error(err: any): void;
end(): void;
}
export interface ListenHandler {
unsubscribe(): void;
pullChanges?: () => void;
}
export interface LiveSetInit<T> {
scheduler?: Scheduler;
read(): Set<T>;
listen(
setValues: { (values: Set<T>): void },
controller: LiveSetController<T>
): void | ListenHandler | (() => void);
}
export type LiveSetSubscriber<T> = (
changes: ReadonlyArray<LiveSetChangeRecord<T>>
) => void;
export interface LiveSetSubscription {
closed: boolean;
unsubscribe(): void;
pullChanges(): void;
}
export interface LiveSetObserver<T> {
start?: null | ((subscription: LiveSetSubscription) => void);
next?: null | LiveSetSubscriber<T>;
error?: null | ((err: any) => void);
complete?: null | (() => void);
}
export default class LiveSet<T> {
static defaultScheduler: Scheduler;
constructor(init: LiveSetInit<T>);
static active<T>(
initialValues: null | void | Set<T>,
options?: null | { scheduler?: Scheduler }
): { liveSet: LiveSet<T>; controller: LiveSetController<T> };
static constant<T>(
values: Set<T>,
options?: null | { scheduler?: Scheduler }
): LiveSet<T>;
values(): Set<T>;
isEnded(): boolean;
getScheduler(): Scheduler;
subscribe(observer: LiveSetObserver<T>): LiveSetSubscription;
subscribe(
onNext: LiveSetSubscriber<T>,
onError?: null | ((err: any) => void),
onComplete?: null | (() => void)
): LiveSetSubscription;
// [Symbol.observable]: any;
}