1 | /**
|
2 | * Handles named events.
|
3 | * @experimental
|
4 | *
|
5 | * This is basically a (better typed) duplicate of Observable, which will replace Observable in the
|
6 | * next release.
|
7 | *
|
8 | * @template {{[key: string]: function(...any):void}} EVENTS
|
9 | */
|
10 | export class ObservableV2<EVENTS extends {
|
11 | [key: string]: (...arg0: any[]) => void;
|
12 | }> {
|
13 | /**
|
14 | * Some desc.
|
15 | * @type {Map<string, Set<any>>}
|
16 | */
|
17 | _observers: Map<string, Set<any>>;
|
18 | /**
|
19 | * @template {string} NAME
|
20 | * @param {NAME} name
|
21 | * @param {EVENTS[NAME]} f
|
22 | */
|
23 | on<NAME extends string>(name: NAME, f: EVENTS[NAME]): EVENTS[NAME];
|
24 | /**
|
25 | * @template {string} NAME
|
26 | * @param {NAME} name
|
27 | * @param {EVENTS[NAME]} f
|
28 | */
|
29 | once<NAME_1 extends string>(name: NAME_1, f: EVENTS[NAME_1]): void;
|
30 | /**
|
31 | * @template {string} NAME
|
32 | * @param {NAME} name
|
33 | * @param {EVENTS[NAME]} f
|
34 | */
|
35 | off<NAME_2 extends string>(name: NAME_2, f: EVENTS[NAME_2]): void;
|
36 | /**
|
37 | * Emit a named event. All registered event listeners that listen to the
|
38 | * specified name will receive the event.
|
39 | *
|
40 | * @todo This should catch exceptions
|
41 | *
|
42 | * @template {string} NAME
|
43 | * @param {NAME} name The event name.
|
44 | * @param {Parameters<EVENTS[NAME]>} args The arguments that are applied to the event listener.
|
45 | */
|
46 | emit<NAME_3 extends string>(name: NAME_3, args: Parameters<EVENTS[NAME_3]>): void;
|
47 | destroy(): void;
|
48 | }
|
49 | /**
|
50 | * Handles named events.
|
51 | *
|
52 | * @deprecated
|
53 | * @template N
|
54 | */
|
55 | export class Observable<N> {
|
56 | /**
|
57 | * Some desc.
|
58 | * @type {Map<N, any>}
|
59 | */
|
60 | _observers: Map<N, any>;
|
61 | /**
|
62 | * @param {N} name
|
63 | * @param {function} f
|
64 | */
|
65 | on(name: N, f: Function): void;
|
66 | /**
|
67 | * @param {N} name
|
68 | * @param {function} f
|
69 | */
|
70 | once(name: N, f: Function): void;
|
71 | /**
|
72 | * @param {N} name
|
73 | * @param {function} f
|
74 | */
|
75 | off(name: N, f: Function): void;
|
76 | /**
|
77 | * Emit a named event. All registered event listeners that listen to the
|
78 | * specified name will receive the event.
|
79 | *
|
80 | * @todo This should catch exceptions
|
81 | *
|
82 | * @param {N} name The event name.
|
83 | * @param {Array<any>} args The arguments that are applied to the event listener.
|
84 | */
|
85 | emit(name: N, args: Array<any>): void;
|
86 | destroy(): void;
|
87 | }
|
88 | //# sourceMappingURL=observable.d.ts.map |
\ | No newline at end of file |