Get an AbortSignal that aborts when the context ends or is cleaned up.
Return the current ambient execution context, or throw an error if none is available.
Is there a current context? (i.e., can you safely use currentContext() or APIs that use it right now?)
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.)
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.)
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.)
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 a new task from an activity, as a child of the currentContext()
Create the Work of a new task, optionally starting activities in it
Wrap an argument-taking function so it will run in (and returns) a new Task when called.
Invoke a no-argument function as a microtask, using queueMicrotask or Promise.resolve().then()
Wait for and return the next value (or error) from a data source (when
processed with yield * within a Coroutine).
Pause for the specified time in ms, e.g. yield *sleep(1000) to wait one
second.
Create an activity that throws a TimeoutError once a timeout is reached
Convert a (possible) promise to something you can yield *to() in a coroutine
Create a resettable watchdog timer for the current context, that will asyncThrow if it ever times out.
Find out whether the active signal is being observed, or just queried.
Arrange for the current signal or rule to recalculate on demand
Subscribe a sink to a stream, returning a task representing the connection.
Asynchronously iterate over an event source
Run a restarting() callback for each value produced by a source.
Pass subscriber into a stream (or any arguments into any other function).
Wait for and return the next value (or error) from a data source (when
processed with yield * within a Coroutine).
A function that does nothing and returns void.
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.
Create a backpressure control function for the given connection
Create an event source and a function to emit events on it
A stream that immediately closes
Convert an async iterable to an event source
Create an event source from an element, window, or other event target
Convert an iterable to a synchronous event source
Convert a Promise to an event source
Create an event source from an arbitrary subscribe/unsubscribe function
Create a source that emits a single given value
Create an event source that issues a number every ms milliseconds (starting
with 0 after the first interval passes).
Create a dynamic source that is created each time it's subscribed
Like emitter, but with a ready() backpressure method. It also only supports a single active subscriber. (Useful for testing stream operators and sinks.)
A stream that never emits or closes
Compose a series of single-argument functions/operators in application order. (This is basically a deferred version of pipe().) For example:
Output multiple streams' contents in order (from an array/iterable of stream sources)
Flatten a source of sources by emitting their contents in series
Map each value of a stream to a substream, then concatenate the resulting substreams
Create a subset of a stream, based on a filter function (like Array.filter)
Replace each value in a stream using a function (like Array.map)
Create an event source by merging an array or iterable of event sources.
Create an event source by merging sources from a stream of event sources
Create an event source by merging sources created by mapping events to sources
Pipe a stream (or anything else) through a series of single-argument functions/operators
Wrap a source to allow multiple subscribers to the same underlying stream
Skip the first N items from a source
Skip items from a stream until another source produces a value.
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.
Add flow control and buffering to a stream
Flatten a source of sources by emitting their contents until a new one arrives.
Map each value of a stream to a substream, then output the resulting substreams until a new value arrives.
Take the first N items from a source
Take items from a source until another source produces a value.
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.
The Result used to indicate a canceled task.
Create an ErrorResult from an error
Fulfill a Promise from a Result
Get the return value from a Result, throwing an appropriate error if the result isn't a ValueResult.
Returns true if the given result is a CancelResult.
Returns true if the given result is a ErrorResult.
Returns true if the given result is a HandledError (an ErrorResult that has been touched by markHandled).
Returns true if the given result is an UnhandledError.
Returns true if the given result is a ValueResult.
Return the error of an ErrorResult and mark it as handled. The ErrorResult is mutated in-place to become a HandledError.
Reject a Request with a reason.
Create a callback that will reject the given Request with a reason.
Resolve a Request with a value.
Create a callback that will resolve the given Request with a value.
Create a ValueResult from a value
Any function
A backpressure controller: returns true if downstream is ready to accept data.
A cancellable task, scope, checkpoint, cleanup context, etc.
A Result that indicates the task was canceled by its creator (via end() or a parent Checkpoint's reset()).
A cancellable and resettable context, allowing you to reuse a context multiple times. (Used for reactive effects and restarting() functions.)
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.
An ambient execution context, for resource cleanup and error reporting
A generator yielding Suspend callbacks
A function that can be called to dispose of something or unsubscribe something. It's called without arguments and returns void.
The iterable returned by yield * each()
The result type returned from calls to Each.next()
A function that emits events, with a .source they're emitted from
A Result that indicates a throw()n or other error.
An asynchronously-expected result (usually produced by a Task) that can be awaited, yielded to, or queried.
An ErrorResult that has been marked "handled" (by being passed to an error-specific handler, converted to a promise, given to markHandled, etc.)
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.
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.
An Emitter with a ready() method, that only supports a single active subscriber. (Useful for testing stream operators and sinks.)
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.)
An undefined or null value
Reactive queries and synchronous callbacks for a present or future Result
An optional cleanup parameter or return.
A function without a this
A subscribable function used to trigger signal recalculations
A request for a value (or error) to be returned asynchronously.
A result passed to a context's cleanup callbacks, or supplied by a future's .result() method.
A cancellable cleanup context with configurable error-reporting scope
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.
The call signatures implemented by signals. (They can be used as sources, or called with no arguments to return a value.)
A Sink is a function that receives data from a 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.
An asynchronous operation that can be waited on by a Coroutine.
A task is a cancellable future: i.e. something that produces an async result, but whose work can be aborted.
Control backpressure for listening streams
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().
An ErrorResult that hasn't yet been "handled" (by being passed to an error-specific handler, converted to a promise, given to markHandled, etc.)
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.)
A Result that provides a return() value.
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.
A pausable computation that ultimately produces a value of type T.
Error thrown when waiting for a result from a future that is canceled.
A timeout error - thrown by watchdog() and timeoutAfter()
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.