UNPKG

nope-js-node

Version:

NoPE Runtime for Nodejs. For Browser-Support please use nope-browser

69 lines (68 loc) 2.64 kB
/** * @author Martin Karkowski * @email m.karkowski@zema.de */ import { BehaviorSubject } from "rxjs"; import { NopeEventEmitter } from "../eventEmitter/nopeEventEmitter"; import { TSubjectOptions } from "../helpers/getSubject"; import { IEventAdditionalData, IEventCallback, INopeObservable, INopeObserver, INopePartialObserver, INopeSubscriptionOptions, IObservableType } from "../types/nope/index"; /** * RsJX based Observable. * * Contains additional Functionalities like: * - property with the current value * - function to publish values. (wrapper for next) * - enables performing a subscription with synced call or a immediate call. */ export declare class NopeObservable<T, S = T, G = T, AD extends IEventAdditionalData = IEventAdditionalData> extends NopeEventEmitter<T, S, G, AD> implements INopeObservable<T, S, G, AD> { protected _options: TSubjectOptions; protected _emitter: BehaviorSubject<IObservableType<G, AD>>; get observable(): BehaviorSubject<IObservableType<G, AD>>; readonly id: string; _value: T; options: any; setContent(value: S | null, options?: Partial<AD>): boolean; /** * Function to set the content of the Observable * @param value * @param sender * @param timeStamp * @param data */ protected _emit(value: S | null, options?: Partial<AD>): boolean; /** * Internal Function to Publish content * * @author M.Karkowski * @protected * @param {G} value The value to use. * @param {Partial<AD>} [options={}] * @return {boolean} * @memberof NopeObservable */ protected _publish(value: G, options?: Partial<AD>): boolean; /** * Function to Force an Update * * @author M.Karkowski * @param {Partial<AD>} options Options which might be relevant * @return {boolean} * @memberof NopeObservable */ forcePublish(options?: Partial<AD>): boolean; /** * Function to extract the Content. * If a Getter is provided, the Getter will be used * to Transform the item. */ getContent(): G | null; protected _lastDataUpdate: number; /** * A Function to subscribe to updates of the Observable. * @param observer The Observer. Could be a Function or a Partial Observer. * @param mode The Mode of the Subscription * @param options Additional Options. */ subscribe(observer: INopePartialObserver<G, AD> | IEventCallback<G, AD>, options?: INopeSubscriptionOptions): INopeObserver; constructor(_options?: TSubjectOptions); }