FromEventObservable.d.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { Observable } from '../Observable';
  2. import { Subscriber } from '../Subscriber';
  3. export declare type NodeStyleEventEmitter = {
  4. addListener: (eventName: string, handler: NodeEventHandler) => void;
  5. removeListener: (eventName: string, handler: NodeEventHandler) => void;
  6. };
  7. export declare type NodeEventHandler = (...args: any[]) => void;
  8. export declare type JQueryStyleEventEmitter = {
  9. on: (eventName: string, handler: Function) => void;
  10. off: (eventName: string, handler: Function) => void;
  11. };
  12. export declare type EventTargetLike = EventTarget | NodeStyleEventEmitter | JQueryStyleEventEmitter | NodeList | HTMLCollection;
  13. export declare type EventListenerOptions = {
  14. capture?: boolean;
  15. passive?: boolean;
  16. once?: boolean;
  17. } | boolean;
  18. export declare type SelectorMethodSignature<T> = (...args: Array<any>) => T;
  19. /**
  20. * We need this JSDoc comment for affecting ESDoc.
  21. * @extends {Ignored}
  22. * @hide true
  23. */
  24. export declare class FromEventObservable<T> extends Observable<T> {
  25. private sourceObj;
  26. private eventName;
  27. private selector;
  28. private options;
  29. static create<T>(target: EventTargetLike, eventName: string): Observable<T>;
  30. static create<T>(target: EventTargetLike, eventName: string, selector: SelectorMethodSignature<T>): Observable<T>;
  31. static create<T>(target: EventTargetLike, eventName: string, options: EventListenerOptions): Observable<T>;
  32. static create<T>(target: EventTargetLike, eventName: string, options: EventListenerOptions, selector: SelectorMethodSignature<T>): Observable<T>;
  33. constructor(sourceObj: EventTargetLike, eventName: string, selector?: SelectorMethodSignature<T>, options?: EventListenerOptions);
  34. private static setupSubscription<T>(sourceObj, eventName, handler, subscriber, options?);
  35. /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<T>): void;
  36. }