(defflow name & flows)
(defflow name parameters & flows)
Creates a flow and binds it a Var named by name
Creates a flow and binds it a Var named by name
(flow description & flows)
Creates a flow which is a composite of flows.
Creates a flow which is a composite of flows.
(fmap f flow)
Creates a flow that returns the application of f to the return of flow
Creates a flow that returns the application of f to the return of flow
(get-state)
(get-state f & args)
Creates a flow that returns the result of applying f (default identity) to state with any additional args.
Creates a flow that returns the result of applying f (default identity) to state with any additional args.
(ignore-error pair)
No-op error handler that simply ignores the error.
No-op error handler that simply ignores the error.
(invoke my-fn)
Creates a flow that invokes a function of no arguments and returns the result. Used to invoke side effects e.g.
(state-flow.core/invoke #(Thread/sleep 1000))
Creates a flow that invokes a function of no arguments and returns the result. Used to invoke side effects e.g. (state-flow.core/invoke #(Thread/sleep 1000))
(log-and-throw-error! pair)
Error handler that logs the error and throws an exception to notify the flow has failed.
Error handler that logs the error and throws an exception to notify the flow has failed.
(match? expected actual & [{:keys [times-to-try sleep-time] :as params}])
Builds a state-flow step which uses matcher-combinators to make an assertion.
expected
can be a literal value or a matcher-combinators matcher
actual
can be a literal value, a primitive step, or a flow
params
are optional keyword-style args, supporting:
:times-to-try optional, default 1 :sleep-time optional, millis to wait between tries, default 200
Given (= times-to-try 1), match? will evaluate actual
just once.
Given (> times-to-try 1), match? will use state-flow-probe/probe
to
retry up to :times-to-try times, waiting :sleep-time between each try,
and stopping when actual
produces a value that matches expected
.
NOTE: when (> times-to-try 1), actual
must be a step or a flow.
Returns a map (in the left value) with information about the success or failure of the match, the details of which are used internally by state-flow and subject to change.
Builds a state-flow step which uses matcher-combinators to make an assertion. `expected` can be a literal value or a matcher-combinators matcher `actual` can be a literal value, a primitive step, or a flow `params` are optional keyword-style args, supporting: :times-to-try optional, default 1 :sleep-time optional, millis to wait between tries, default 200 Given (= times-to-try 1), match? will evaluate `actual` just once. Given (> times-to-try 1), match? will use `state-flow-probe/probe` to retry up to :times-to-try times, waiting :sleep-time between each try, and stopping when `actual` produces a value that matches `expected`. NOTE: when (> times-to-try 1), `actual` must be a step or a flow. Returns a map (in the left value) with information about the success or failure of the match, the details of which are used internally by state-flow and subject to change.
(return v)
Creates a flow that returns v. Use this as the last step in a flow that you want to reuse in other flows, in order to clarify the return value, e.g.
(def increment-count (flow "increments :count and returns it" (state/modify update :count inc) [new-count (state/gets :count)] (state-flow/return new-count)))
Creates a flow that returns v. Use this as the last step in a flow that you want to reuse in other flows, in order to clarify the return value, e.g. (def increment-count (flow "increments :count and returns it" (state/modify update :count inc) [new-count (state/gets :count)] (state-flow/return new-count)))
(run flow)
(run flow initial-state)
Given an initial-state (default {}), runs a flow and returns a tuple of the result of the last step in the flow and the end state.
Given an initial-state (default {}), runs a flow and returns a tuple of the result of the last step in the flow and the end state.
(run* {:keys [init cleanup runner on-error]
:or {init (constantly {})
cleanup identity
runner run
on-error log-and-throw-error!}
:as opts}
flow)
Runs a flow with specified parameters. Use run
unless you need
the customizations run*
supports.
Supported keys in the first argument are:
init
optional, default (constantly {}), function of no arguments that returns the initial state
cleanup
optional, default identity, function of the final state used to perform cleanup, if necessary
runner
optional, default run
, function of a flow and an initial state which will execute the flow
on-error
optional, default log-and-throw-error!
, function of the final result pair to be invoked
when the first value in the pair represents an error
Runs a flow with specified parameters. Use `run` unless you need the customizations `run*` supports. Supported keys in the first argument are: `init` optional, default (constantly {}), function of no arguments that returns the initial state `cleanup` optional, default identity, function of the final state used to perform cleanup, if necessary `runner` optional, default `run`, function of a flow and an initial state which will execute the flow `on-error` optional, default `log-and-throw-error!`, function of the final result pair to be invoked when the first value in the pair represents an error
(swap-state f & args)
Creates a flow that replaces state with the result of applying f to state with any additional args.
Creates a flow that replaces state with the result of applying f to state with any additional args.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close