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 {:keys [initialize augment executor] :as opts})
Run a series of potentially asynchronous steps in sequence
on an initial value (init
0, threading each step's result to
the next step as input.
Steps are maps or the following keys:
[:id :handler :in :out :discard? :guard]
id
is the unique ID for a stephandler
is the function of the previous resultin
when present determines which path in the context will
be fed to the handler. The handler is considered a function
of the contexout
when present determines which path in the context to
associate the result to, otherwise replaces the full contextdiscard?
when present, runs the handler but pass the context
untouched to the next stepguard
is an optional predicate of the current context and previous
preventing execution of the step when yielding falseIn the three-arity version, an extra options maps can be provided, with the following keys:
[:augment :executor]
augment
is a function called on the context for each step,
expected to yield an updated context. This can useful to
perform timing tasksexecutor
a manifold executor to execute deferreds onRun a series of potentially asynchronous steps in sequence on an initial value (`init`0, threading each step's result to the next step as input. Steps are maps or the following keys: [:id :handler :in :out :discard? :guard] - `id` is the unique ID for a step - `handler` is the function of the previous result - `in` when present determines which path in the context will be fed to the handler. The handler is considered a function of the contex - `out` when present determines which path in the context to associate the result to, otherwise replaces the full context - `discard?` when present, runs the handler but pass the context untouched to the next step - `guard` is an optional predicate of the current context and previous preventing execution of the step when yielding false In the three-arity version, an extra options maps can be provided, with the following keys: [:augment :executor] - `augment` is a function called on the context for each step, expected to yield an updated context. This can useful to perform timing tasks - `executor` a manifold executor to execute deferreds on
(step handler)
(step id handler & {:as params})
Convenience function to build a step map. Requires and ID and handler, and can be fed additional options
Convenience function to build a step map. Requires and ID and handler, and can be fed additional options
(step* id handler {:keys [in out lens guard discard?]})
Convenience function to build a step map. Requires and ID and handler, and can be fed additional options
Convenience function to build a step map. Requires and ID and handler, and can be fed additional options
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close