(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 ignores the error.
No-op error handler that 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)
DEPRECATED: Use (comp throw-error! log-error) instead.
DEPRECATED: Use (comp throw-error! log-error) instead.
(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 fail-fast?]
:or {init (constantly {})
cleanup identity
runner run
fail-fast? false
on-error (comp throw-error!
log-error
(filter-stack-trace default-stack-trace-exclusions))}
: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:
:fail-fast?
optional, default false
, when set to true
, the flow stops running after the first failing assertion
: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, function of the final result pair to be invoked when the first value in the pair
represents an error, default:
`(comp throw-error!
log-error
(filter-stack-trace default-strack-trace-exclusions))`
Runs a flow with specified parameters. Use `run` unless you need the customizations `run*` supports. Supported keys in the first argument are: `:fail-fast?` optional, default `false`, when set to `true`, the flow stops running after the first failing assertion `: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, function of the final result pair to be invoked when the first value in the pair represents an error, default: `(comp throw-error! log-error (filter-stack-trace default-strack-trace-exclusions))`
(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