Function after

  • after is a more readable version of setTimeout, implemented as an await-able Observable. after is lazy, and cancelable like an Observable, and then-able and await-able like a Promise.

    after is single-valued if a primitive or thunk is its 2nd argument, multivalued if an Observable. For a delay of 0, the value is given synchronously when .subscribe() is called.

    Returns

    An await-able Observable of the object, thunk return value, or Observable's notification(s).

    Argument

    delayArg Either a number of milliseconds, a Promise, setTimeout, or requestAnimationFrame

    Argument

    valueProvider Can be a value, a function returning a value, or an Observable.

    Argument

    observer A TapObserver that can handle subscription or value events.

    See

    https://www.youtube.com/watch?v=Bvsb9Qy1V9g for how after can be thought of as a 2-dimensional value, a composable vector in the 2-D space of time and values.

    Example

    after(0, value)            # sync value
    after(N, value) # delayed value
    after(N, ()=>value)) # delayed call
    after(N, Observable)) # delayed Obs.
    after(Promise, ()=>value)) # chained Promise
    after(N, value, {next}) # with Observer
    after(setTimeout, v) # setTimeout(0)
    after(rAF, v) # ani. frame

    Type Parameters

    • T

    Parameters

    • delayArg: number | Promise<any> | typeof setTimeout
    • Optional valueProvider: T | Observable<T> | ((v?: T) => T)
    • Optional observer: TapObserver<T>

    Returns Observable<T> & Promise<T>

Generated using TypeDoc