Create an Operation that can be either resolved (or rejected) with
a synchronous callback. This is the Effection equivalent of new Promise()
.
Block and wait for all of the given operations to complete. Returns an array of values that the given operations evaluated to. This has the same purpose as Promise.all.
Pause the current operation, then run an async function, or operation function in a new scope. The calling operation will be resumed (or errored) once call is completed.
A uniform integration type representing anything that can be evaluated as a the parameter to call.
Create a new Channel. Use channels to communicate between operations. In order to dispatch messages from outside an operation such as from a callback, use Signal.
Creates a new queue. Queues are unlimited in size and sending a message to a queue is always synchronous.
Create a new scope to serve as an entry point from normal JavaScript execution into Effection.
Create a new Signal
Consume an effection stream using a simple for-of loop.
Run the given function or operation when the current operation
shuts down. This is equivalent to running the function or operation
in a finally {}
block, but it can help you avoid rightward drift.
Halt process execution immediately and initiate shutdown. If a message is provided, it will be logged to the console after shutdown:
A value that is both an Operation and Promise
.
Convert a simple function into an Operation
Top-level entry point to programs written in Effection. That means that your
program should only call main
once, and everything the program does is
handled from within main
including an orderly shutdown. Unlike run
, main
automatically prints errors that occurred to the console.
Create a Stream of events from any EventTarget.
Create an Operation that yields the next event to be emitted by an EventTarget.
An Operation
in Effection describes an abstract computation. An operation
does not do anything on its own. Rather, it only describes the steps it will
take when it runs.
Race the given operations against each other and return the value of whichever operation returns first. This has the same purpose as Promise.race.
Execute an operation.
Sleep for the given amount of milliseconds.
Run another operation concurrently as a child of the current one.
The Effection equivalent of an AsyncIterable
.
Convert any AsyncIterable
into an Effection Stream.
Convert any AsyncIterator
into an effection Subscription
Indefinitely pause execution of the current operation. It is typically used in conjunction with an action to mark the boundary between setup and teardown.
Create an
AbortSignal
bound to the current scope. Whenever that scope is completed,
errored, or halted, the abort signal will be triggered.
Get the scope of the currently running Operation.