Function executeLatestOnIdle

  • Calls the given execute function with the latest value from the source observable as soon as a running call of executeFun finished.

    Example:

    • source emitted 1 -> emit StartedEvent 1 to subscriber, call executeFun with 1

    • executeFun finished 1 -> emit FinishedEvent 1 to subscriber

    • source emitted 2 -> emit StartedEvent 2 to subscriber, call executeFun with 2

    • source emitted 3 -> cache 3 because executeFun didn't finished for 2 yet

    • executeFun finished 2 -> emit FinishedEvent 2 to subscriber, emit StartedEvent 3 to subscriber, call executeFun with 3

    • source emitted 4 -> cache 4 because executeFun didn't finished for 3 yet

    • source emitted 5 -> emit SkippedEvent for 4 and cache 5 because executeFun didn't finished for 3 yet

    • executeFun finished 3 -> emit FinishedEvent 3 to subscriber, emit StartedEvent 5 to subscriber, call executeFun with 5

    • source completed -> executeFun didn't finished for 5 yet, delay completion

    • executeFun finished 5 -> emit FinishedEvent 6 to subscriber, complete subscriber

    Error Handling:

    • For errors caused by the execute function, an ErrorEvent will be emitted to the subscriber.

    • Errors of the source observable will be passed through.

    Type Parameters

    • T

    • R = void

    Parameters

    • executeFun: ((t) => R | Promise<R>)

      Function to execute with latest value from source observable. Can return something synchronously or asynchronously. Returned value will be included in FinishedEvent.

        • (t): R | Promise<R>
        • Parameters

          • t: T

          Returns R | Promise<R>

    Returns OperateFunction<T, R>

Generated using TypeDoc