Function keep

  • Converts a Promise into an Observable which fires once. Any exceptions thrown while awaiting the promise will be re-thrown. If an exception is thrown the observer will definitely not be called.

    Type Parameters

    • A

    Parameters

    • promise: PromiseLike<A>

    Returns Observable<A>

    Remarks

    A Promise may be thought of as a linear Observable; an Observable may be thought of as a non-linear Promise.

    Example

    const promise = keep(new Promise((resolve) => {
    setTimeout(() => {
    resolve("hello from 2 seconds ago");
    }, 2000);
    }));
    const activity = promise.subscribe(
    (msg: string) => void console.log(msg)
    );

    Example

    # prints
    hello from 2 seconds ago

Generated using TypeDoc