import { IObservable, IObservableConstructor, IObservableTypedConstructor } from '../../../core/observable/interfaces'; import { INotificationsObserver } from '../notifications-observer/interfaces'; import { KeyValueMapGenericConstraint, KeyValueMapKeys, KVRecord } from '../interfaces'; import { IObserver } from '../../../core/observer/interfaces'; import { IObservableObserver } from '../../../core/observable-observer/interfaces'; import { TObservableObservedByResultNonCyclic, TObservablePipeThroughResult, TObservablePipeToCallbackResult, TObservablePipeToObserverResult, TObserverOrCallback } from '../../../core/observable/types'; import { INotificationsObservableContext } from './context/interfaces'; import { INotificationsObservableMatchOptions, KeyValueMapToNotifications, TNotificationsObservableHook, TNotificationsObservablePipeThroughResult, TNotificationsObservablePipeToObserverResult } from './types'; /** INTERFACES **/ export interface INotificationsObservableConstructor extends Omit { new>(create?: (context: INotificationsObservableContext) => (TNotificationsObservableHook | void)): INotificationsObservable; } export interface INotificationsObservableTypedConstructor> extends Omit>, 'new'> { new(create?: (context: INotificationsObservableContext) => (TNotificationsObservableHook | void)): INotificationsObservable; } /** * A NotificationsObservable is an Observable emitting some Notifications. * It provides some shortcut functions to create Observers. */ export interface INotificationsObservable> extends IObservable> { pipeTo>(observer: NO): TNotificationsObservablePipeToObserverResult; pipeTo>(observer: O): TObservablePipeToObserverResult>; pipeTo void>(callback: C): TObservablePipeToCallbackResult>; pipeThrough, IObservable>>(observableObserver: OO): TNotificationsObservablePipeThroughResult; pipeThrough, IObservable>>(observableObserver: OO): TObservablePipeThroughResult>; // creates a NotificationsObserver with "name" and "callback" which observes this Observable addListener>(name: TKey, callback: (value: TKVMap[TKey]) => void): INotificationsObserver; // removes the Observable's NotificationsObservers matching "name" and "callback" removeListener>(name: TKey, callback?: (value: TKVMap[TKey]) => void): void; // like "addListener" but returns "this" on>(name: TKey, callback: (value: TKVMap[TKey]) => void): this; // like "removeListener" but returns "this" off>(name: TKey, callback?: (value: TKVMap[TKey]) => void): this; /** * Returns true if this observable has an Observer matching "name" and "callback". * If 'callback' is not defined, searches only for 'name' * If options.includeGlobalObservers is true, and this Observable is observed by at least one Observer with a type different than NotificationsObserver, then returns true. */ hasListener(name: string, callback?: (value: any) => void, options?: INotificationsObservableMatchOptions): boolean; /** * Returns the list of Observer matching "name" and "callback" * If 'callback' is not defined, searches only for 'name' * If options.includeGlobalObservers is true, includes the list of Observers with a type different than NotificationsObserver. */ matches(name: string, callback?: (value: any) => void, options?: INotificationsObservableMatchOptions): Generator>, void, undefined>; // matches(name: string, callback?: (value: any) => void): IterableIterator>; } export interface IBaseNotificationsObservable extends INotificationsObservable> { observedBy[]>(...observers: O): TObservableObservedByResultNonCyclic>, this>; // returns this }