-
Notifications
You must be signed in to change notification settings - Fork 1
/
interfaces.ts
44 lines (35 loc) · 1.84 KB
/
interfaces.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
import { INotificationsObservable } from '../../../core/notifications-observable/interfaces';
import { KeyValueMapKeys } from '../../../core/interfaces';
import { Targets } from '../events-listener/from/event-target/target-to-event-map';
import { IEventsListener } from '../events-listener/interfaces';
import { CastTargetToEventsObservable, EventKeyValueMapConstraint } from './types';
/** INTERFACES **/
export interface IEventsObservableConstructor {
new<TTarget extends Targets>(target: TTarget): CastTargetToEventsObservable<TTarget>;
new<TKVMap extends EventKeyValueMapConstraint<TKVMap>, TTarget extends IEventsListener = IEventsListener>(target: TTarget, name?: KeyValueMapKeys<TKVMap> | null): IEventsObservable<TKVMap, TTarget>;
}
/**
* An EventsObservable is a wrapper around a NotificationsObservable,
* which allows to listen to the Events emitted by 'target'.
* To force an Event's type you may provide a 'name', else the Event's type will be determined by the NotificationsObservers observing it.
*/
export interface IEventsObservable<TKVMap extends EventKeyValueMapConstraint<TKVMap>, TTarget extends IEventsListener = IEventsListener> extends INotificationsObservable<TKVMap> {
// the target of the events' listener
readonly target: TTarget;
// optional name of the event to listen to
readonly name: KeyValueMapKeys<TKVMap> | null;
}
/*-------------*/
// const a: IEventsObservableConstructor = null;
// const b = new a(window);
//
// new a(new FileReader())
// .on('load', () => {
// })
// .on('resize', () => {
// });
// const a: AbortSignalEventMap extends { [key: string]: Event } ? true : false;
// const b: IEventsObservable<AbortSignalEventMap> = null;
// const b: IEventsObservable<AbortSignalEventMap & AbstractWorkerEventMap> = null;
// const b: IEventsObservable<{ a: 1 }> = null;
// const b: IEventsObservable<never> = null;