Function fromSubscribe

  • Create an event source from an arbitrary subscribe/unsubscribe function

    The supplied "subscribe" function will be passed a 1-argument callback and must return an unsubscribe function. The callback should be called with events of the appropriate type, and the unsubscribe function will be called when the connection is closed.

    (Note: it's okay if the act of subscribing causes an immediate callback, as the subscribe function will be called in a separate microtask.)

    Type Parameters

    • T

    Parameters

    • subscribe: ((cb: ((val: T) => void)) => DisposeFn)
        • (cb: ((val: T) => void)): DisposeFn
        • Parameters

          • cb: ((val: T) => void)
              • (val: T): void
              • Parameters

                • val: T

                Returns void

          Returns DisposeFn

    Returns Source<T>