Uneventful
    Preparing search index...

    uneventful

    This is the default export of uneventful, which contains the API for tasks and streams, as well as any signals-related APIs that don't depend on the signals framework (like recalcWhen() and isObserved(), which do nothing if the signals framework isn't in use, and won't cause it to be imported).

    For the rest of the signals API, see the uneventful/signals export.

    Tasks and Context

    abortSignal

    Get an AbortSignal that aborts when the context ends or is cleaned up.

    currentContext

    Return the current ambient execution context, or throw an error if none is available.

    inContext

    Is there a current context? (i.e., can you safely use currentContext() or APIs that use it right now?)

    must

    Add a cleanup function to the active context. Non-function values are ignored. Equivalent to calling .must() on the current contet. (See Context.must() for more details.)

    nativePromise

    Obtain a native promise for a Future or Task

    newRoot

    Create a new root scope (usually for testing purposes). If there is an existing root scope, it is ended first. The new root inherits the previous root scope's .asyncCatch() handler, if it had one. (Otherwise, the new root is configured to convert async errors into unhandled promise rejections by default.)

    restarting

    Wrap a function in a Checkpoint that resets each time the resulting function is called, thereby canceling any in-progress subtasks and cleaning up any resources used by previous calls. (This can be useful for such things as canceling an in-progress search when the user types more text in a field.)

    root

    The "main" context of the program or bundle, which all other tasks and contexts should be a child of. This provides a single point of configuration and cleanup, as one can e.g.:

    start

    Start a new task from an activity, as a child of the currentContext()

    starting

    Create the Work of a new task, optionally starting activities in it

    task

    Wrap an argument-taking function so it will run in (and returns) a new Task when called.

    Scheduling

    defer

    Invoke a no-argument function as a microtask, using queueMicrotask or Promise.resolve().then()

    next

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

    sleep

    Pause for the specified time in ms, e.g. yield *sleep(1000) to wait one second.

    timeoutAfter

    Create an activity that throws a TimeoutError once a timeout is reached

    to

    Convert a (possible) promise to something you can yield *to() in a coroutine

    watchdog

    Create a resettable watchdog timer for the current context, that will asyncThrow if it ever times out.

    Signals

    isObserved

    Find out whether the active signal is being observed, or just queried.

    recalcWhen

    Arrange for the current signal or rule to recalculate on demand

    Stream Consumers

    connect

    Subscribe a sink to a stream, returning a task representing the connection.

    each

    Asynchronously iterate over an event source

    forEach

    Run a restarting() callback for each value produced by a source.

    into

    Pass subscriber into a stream (or any arguments into any other function).

    next

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

    noop

    A function that does nothing and returns void.

    throttle

    Create a backpressure controller for a stream. Pass it to one or more sources you're connecting to, and if they support backpressure they'll respond when you call its .pause() and .resume() methods.

    Stream Producers

    backpressure

    Create a backpressure control function for the given connection

    emitter

    Create an event source and a function to emit events on it

    empty

    A stream that immediately closes

    fromAsyncIterable

    Convert an async iterable to an event source

    fromDomEvent

    Create an event source from an element, window, or other event target

    fromIterable

    Convert an iterable to a synchronous event source

    fromPromise

    Convert a Promise to an event source

    fromSubscribe

    Create an event source from an arbitrary subscribe/unsubscribe function

    fromValue

    Create a source that emits a single given value

    interval

    Create an event source that issues a number every ms milliseconds (starting with 0 after the first interval passes).

    lazy

    Create a dynamic source that is created each time it's subscribed

    mockSource

    Like emitter, but with a ready() backpressure method. It also only supports a single active subscriber. (Useful for testing stream operators and sinks.)

    never

    A stream that never emits or closes

    Stream Operators

    compose

    Compose a series of single-argument functions/operators in application order. (This is basically a deferred version of pipe().) For example:

    concat

    Output multiple streams' contents in order (from an array/iterable of stream sources)

    concatAll

    Flatten a source of sources by emitting their contents in series

    concatMap

    Map each value of a stream to a substream, then concatenate the resulting substreams

    filter

    Create a subset of a stream, based on a filter function (like Array.filter)

    map

    Replace each value in a stream using a function (like Array.map)

    merge

    Create an event source by merging an array or iterable of event sources.

    mergeAll

    Create an event source by merging sources from a stream of event sources

    mergeMap

    Create an event source by merging sources created by mapping events to sources

    pipe

    Pipe a stream (or anything else) through a series of single-argument functions/operators

    share

    Wrap a source to allow multiple subscribers to the same underlying stream

    skip

    Skip the first N items from a source

    skipUntil

    Skip items from a stream until another source produces a value.

    skipWhile

    Skip items from a stream until a given condition is false, then output all remaining items. The condition function is not called again once it returns false.

    slack

    Add flow control and buffering to a stream

    switchAll

    Flatten a source of sources by emitting their contents until a new one arrives.

    switchMap

    Map each value of a stream to a substream, then output the resulting substreams until a new value arrives.

    take

    Take the first N items from a source

    takeUntil

    Take items from a source until another source produces a value.

    takeWhile

    Take items from a stream until a given condition is false, then close the output. The condition function is not called again after it returns false.

    Requests and Results

    CancelResult

    The Result used to indicate a canceled task.

    ErrorResult

    Create an ErrorResult from an error

    fulfillPromise

    Fulfill a Promise from a Result

    getResult

    Get the return value from a Result, throwing an appropriate error if the result isn't a ValueResult.

    isCancel

    Returns true if the given result is a CancelResult.

    isError

    Returns true if the given result is a ErrorResult.

    isHandled

    Returns true if the given result is a HandledError (an ErrorResult that has been touched by markHandled).

    isUnhandled

    Returns true if the given result is an UnhandledError.

    isValue

    Returns true if the given result is a ValueResult.

    markHandled

    Return the error of an ErrorResult and mark it as handled. The ErrorResult is mutated in-place to become a HandledError.

    propagateResult

    Propagate a Result to another task via its Work context

    reject

    Reject a Request with a reason.

    rejecter

    Create a callback that will reject the given Request with a reason.

    resolve

    Resolve a Request with a value.

    resolver

    Create a callback that will resolve the given Request with a value.

    ValueResult

    Create a ValueResult from a value

    Types and Interfaces

    Activity

    A thread of parallel, asynchronous execution within the Work of a Task

    ActivityFn

    A function implementing a Task, or an Activity within a task

    AnyFunction

    Any function

    Backpressure

    A backpressure controller: returns true if downstream is ready to accept data.

    Cancellable

    A cancellable task, scope, checkpoint, cleanup context, etc.

    CancelResult

    A Result that indicates the task was canceled by its creator (via end() or a parent Checkpoint's reset()).

    Checkpoint

    A cancellable and resettable context, allowing you to reuse a context multiple times. (Used for reactive effects and restarting() functions.)

    CleanupFn

    A cleanup function is a callback invoked when a cleanup context is ended or reset. It receives a result that indicates whether the context ended itself with a return value or error, or was canceled/reset by its creator.

    Completion

    Interface for completing a Future or Task with a return value or error.

    Context

    An ambient execution context, for resource cleanup and error reporting

    Coroutine

    A generator yielding Suspend callbacks

    DisposeFn

    A function that can be called to dispose of something or unsubscribe something. It's called without arguments and returns void.

    Each

    The iterable returned by yield * each()

    EachResult

    The result type returned from calls to Each.next()

    Emitter

    A function that emits events, with a .source they're emitted from

    ErrorResult

    A Result that indicates a throw()n or other error.

    Eventual

    An object that eventually produces a value (such as a Coroutine, Task, or Future)

    EventuallyReturns

    An Activity function that returns an Eventual value (such as a Coroutine or a promise/promiselike object).

    Future

    An asynchronously-expected result (usually produced by a Task) that can be awaited, yielded to, or queried.

    HandledError

    An ErrorResult that has been marked "handled" (by being passed to an error-specific handler, converted to a promise, given to markHandled, etc.)

    Inlet

    Control backpressure for listening streams. This interface is the API internal to the implementation of backpressure(). Unless you're implementing a backpressurable stream yourself, see the Throttle interface instead.

    IsStream

    A specially-typed string used to verify that a function supports uneventful's streaming protocol. Return it from a function to implement the Source type.

    MockSource

    An Emitter with a ready() method, that only supports a single active subscriber. (Useful for testing stream operators and sinks.)

    NextMethod

    An object that can be waited on with yield *next(), by calling its "uneventful.next" method. (This mostly exists to allow Signals to optimize their next() implementation, but is also open for extensions.)

    Nothing

    An undefined or null value

    ObservableResult

    Reactive queries and synchronous callbacks for a present or future Result

    OptionalCleanup

    An optional cleanup parameter or return.

    PlainFunction

    A function without a this

    RecalcSource

    A subscribable function used to trigger signal recalculations

    Request

    A request for a value (or error) to be returned asynchronously.

    Result

    A result passed to a context's cleanup callbacks, or supplied by a future's .result() method.

    Scope

    A cancellable cleanup context with configurable error-reporting scope

    Setup

    An Activity function that sets up event listeners, effects, or other ways to do the work of a task, optionally marking the work as completed.

    SignalSource

    The call signatures implemented by signals. (They can be used as sources, or called with no arguments to return a value.)

    Sink

    A Sink is a function that receives data from a Stream.

    Source

    A Source is a function that can be called to arrange for data to be produced and sent to a Sink function for consumption, until the connection's Task is ended (either by the source or the sink, e.g. via .end() if the sink doesn't want more data or .return() if the source has no more to send).

    Stream

    An uneventful stream is either a Source or a SignalSource. (Signals actually implement the Source interface as an overload, but TypeScript gets confused about that sometimes, so we generally declare our stream inputs as Stream<T> and our stream outputs as Source, so that TypeScript knows what's what.

    Suspend

    An asynchronous operation that can be waited on by a Coroutine.

    Task

    A task is a cancellable future: i.e. something that produces an async result, but whose work can be aborted.

    Throttle

    Control backpressure for listening streams

    Transformer

    A Transformer is a function that takes one stream and returns another, possibly one that produces data of a different type. Most operator functions return a transformer, allowing them to be combined via pipe().

    UnhandledError

    An ErrorResult that hasn't yet been "handled" (by being passed to an error-specific handler, converted to a promise, given to markHandled, etc.)

    UntilMethod

    An object that can be waited on with yield *until(), by calling its "uneventful.until" method. (This mostly exists to allow Signals to optimize their until() implementation, but is also open for extensions.)

    ValueResult

    A Result that provides a return() value.

    Work

    A Work context is a task's Scope and Completion: the interface used to .exec() the task's activities, register cleanups, capture async errors, and determine the task's final Result.

    Yieldable

    A pausable computation that ultimately produces a value of type T.

    Errors

    CancelError

    Error thrown when waiting for a result from a future that is canceled.

    TimeoutError

    A timeout error - thrown by watchdog() and timeoutAfter()