Liking cljdoc? Tell your friends :D

state-flow.api


defflowcljmacro

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

flowcljmacro

(flow description & flows)

Creates a flow which is a composite of flows.

Creates a flow which is a composite of flows.
sourceraw docstring

fmapclj

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

get-stateclj

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

ignore-errorclj

(ignore-error pair)

No-op error handler that simply ignores the error.

No-op error handler that simply ignores the error.
sourceraw docstring

invokeclj

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

log-and-throw-error!clj

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

match?cljmacro

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

returnclj

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

runclj

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

run*clj

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

swap-stateclj

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

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

× close