Function next

  • Wait for and return the next value (or error) from a data source (when processed with yield * within a Job).

    This differs from until() in that it waits for the next value (truthy or not!), and it never resumes immediately for signals, but instead waits for the signal to change. (Also, it does not support zero-argument functions, unless you wrap them with cached() first.)

    Type Parameters

    • T

    Parameters

    • source: NextMethod<T> | Stream<T>

      The source to wait on, which can be:

      • An object with an "uneventful.next" method returning a Yielding (in which case the result will be the the result of calling that method)
      • A Signal or Source (in which case the job resumes on the next value it produces)

      (Note: if the supplied source is a function with a non-zero .length, it is assumed to be a Source.)

    Returns Yielding<T>

    a Yieldable that when processed with yield * in a job, will return the triggered event, or signal value. An error is thrown if event stream throws or closes early, or the signal throws.