UNPKG

sub-events

Version:

Lightweight, strongly-typed events, with monitored subscriptions.

18 lines (17 loc) 749 B
import { IEmitOptions, ISubOptions, SubEvent, SubFunction, Subscription } from '../dist/src'; /** * Returns a new TimeoutEvent that triggers a fresh setTimeout on each subscribe, * and cancels the subscription after the timer event. * * And if the client cancels the subscription first, the event won't happen. */ export declare function fromTimeout(timeout?: number, options?: IEmitOptions): TimeoutEvent; /** * Implements a timeout event, with automatically cancelled subscriptions. * * A new timeout is started for every fresh subscriber. */ export declare class TimeoutEvent extends SubEvent<void> { constructor(timeout?: number, options?: IEmitOptions); subscribe(cb: SubFunction<void>, options?: ISubOptions): Subscription; }