Control backpressure for listening streams

Obtain instances via throttle(), then pass them into the appropriate stream-consuming API. (e.g. connect).

interface Throttle {
    isOpen(): boolean;
    isReady(): boolean;
    onReady(cb: (() => any), job: Job<any>): this;
    pause(): void;
    resume(): void;
}

Hierarchy (view full)

Methods

  • Is the main connection open? (i.e. is the creating job not closed yet?)

    Returns boolean

  • Register a callback to produce more data when the inlet is resumed (The callback is unregistered if the supplied job ends.)

    Parameters

    • cb: (() => any)
        • (): any
        • Returns any

    • job: Job<any>

    Returns this

  • Un-pause, and iterate backpressure-able sources' onReady callbacks to resume sending immediately. (i.e., synchronously!)

    Returns void