Convention based lifecycle management of asynchronous chains. This implements a lightweight take on the ideas behind interceptors and similar libraries.
Notable differences are:
Convention based lifecycle management of asynchronous chains. This implements a lightweight take on the ideas behind interceptors and similar libraries. Notable differences are: - Manifold is the sole provided execution model for chains - No chain manipulation can occur - Guards and finalizer for steps are optional - Exceptions during lifecycle steps stop the execution
(run init steps)(run init steps opts)Run a series of potentially asynchronous steps in sequence
on an initial value (init0, threading each step's result to
the next step.
Steps are maps or the following keys:
[:manifold.lifecycle/id
:manifold.lifecycle/handler
:manifold.lifecycle/show-context?
:manifold.lifecycle/guard]
id is the unique ID for a stephandler is the function of the previous resultshow-context? determines whether the handler is fed
the context map or the result. When false, the output
is considered to be the result, not the context.guard is an optional predicate of the current context and previous
preventing execution of the step when yielding falseSteps can also be provided as functions or vars, in which case it is
assumed that show-context? is false for the step, and ID is inferred
or generated.
In the three-arity version, an extra options maps can be provided, with the following keys:
[:manifold.lifecycle/clock
:manifold.lifecycle/raw-result?]
clock is an optional implementation of spootnik.clock/Clock,
defaulting to the system's wall clock (spootnik.clock/wall-clock)raw-result? toggles extraction of the result out of the context
map, defaults to false
Run a series of potentially asynchronous steps in sequence
on an initial value (`init`0, threading each step's result to
the next step.
Steps are maps or the following keys:
[:manifold.lifecycle/id
:manifold.lifecycle/handler
:manifold.lifecycle/show-context?
:manifold.lifecycle/guard]
- `id` is the unique ID for a step
- `handler` is the function of the previous result
- `show-context?` determines whether the handler is fed
the context map or the result. When false, the output
is considered to be the result, not the context.
- `guard` is an optional predicate of the current context and previous
preventing execution of the step when yielding false
Steps can also be provided as functions or vars, in which case it is
assumed that `show-context?` is false for the step, and ID is inferred
or generated.
In the three-arity version, an extra options maps can
be provided, with the following keys:
[:manifold.lifecycle/clock
:manifold.lifecycle/raw-result?]
- `clock` is an optional implementation of `spootnik.clock/Clock`,
defaulting to the system's wall clock (`spootnik.clock/wall-clock`)
- `raw-result?` toggles extraction of the result out of the context
map, defaults to `false`
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |