Liking cljdoc? Tell your friends :D
Clojure only.

manifold.lifecycle

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
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
raw docstring

runclj

(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 as input.

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
  • context? determines whether the handler is fed the context map or the plain input. 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 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/context?]
  • clock is an optional implementation of spootnik.clock/Clock, defaulting to the system's wall clock (spootnik.clock/wall-clock)
  • context? 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 as input.

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
- `context?` determines whether the handler is fed
  the context map or the plain input. 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 `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/context?]

- `clock` is an optional implementation of `spootnik.clock/Clock`,
  defaulting to the system's wall clock (`spootnik.clock/wall-clock`)
- `context?` toggles extraction of the result out of the context
  map, defaults to `false`
 
sourceraw docstring

stepclj

(step id handler & {:keys [context? guard]})

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
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close