(async-action key state action handler-promise-or-async-handler-map)
a promise-based async action handler providing a consistent
format for handling and recording emerging async-action-state
, and
for interacting with navigation
key
: the ::action/key
to match a dispatch
. identifies the action,
and is the default path of the async-action-state
in state
state
: the global stateaction
: the action value being handled
::action/path
- instead of updating the state
at key
,
update the state
at path
handler-promise-or-async-handler-map
: a promise of a result,
or a map {::action/async
Promise<action-result>
::action/navigate
[-*] <url>
}async-action-state
will be updated at ::action-path
with a map
with these keys:
::action/status
- ::inflight, ::success or ::error
::action/action
- the action value
::action/result
- the result value
::action/error
- any error value
if an ::action/navigate
url is supplied then it will be used to
navigate each time the action is handled (including
::action/inflight
)
::action/navigate-inflight
, ::action/navigate-success
and
::action/navigate-error
keys are also available to navigate
only on particular conditions
a promise-based async action handler providing a consistent format for handling and recording emerging `async-action-state`, and for interacting with navigation - `key` : the `::action/key` to match a `dispatch`. identifies the action, and is the default path of the `async-action-state` in `state` - `state` : the global state - `action` : the action value being handled - `::action/path` - instead of updating the `state` at `key`, update the `state` at `path` - `handler-promise-or-async-handler-map` : a promise of a result, or a map {`::action/async` `Promise<action-result>` `::action/navigate`[-*] `<url>`} `async-action-state` will be updated at `::action-path` with a map with these keys: `::action/status` - ::inflight, ::success or ::error `::action/action` - the action value `::action/result` - the result value `::action/error` - any error value if an `::action/navigate` url is supplied then it will be used to navigate each time the action is handled (including `::action/inflight`) `::action/navigate-inflight`, `::action/navigate-success` and `::action/navigate-error` keys are also available to navigate only on particular conditions
(def-async-action key
[_state-bindings _async-action-state-bindings _action-bindings
:as bindings]
handler-promise-or-async-handler-map)
define an action handler to service a promise-based async action
an async-action-state
map will be initialised at a path in the global
state
map, and updated after the action has completed.
async-action-state
will have shape:
{::action/status
::inflight|::success|::error
::action/action
<action-map>
::action/data
<action-data>
::action/error
<action-error>
}
key
: the action key and the default path in the state
for
the async-action-state
state-bindings
: fn bindings to destructure the global state
mapasync-action-state-bindings
: fn bindings to destructure the async-action-state
mapaction-bindings
: fn bindings to destructure the action
maphandler-promise-or-async-handler-map
: form returning a promise of
the <action-data>
or a map with shape:
{::a/async
Promise<action-data>
::a/navigate
[-*] <url>
}
may refer to any of the destructured bindingsdefine an action handler to service a promise-based async action an `async-action-state` map will be initialised at a path in the global `state` map, and updated after the action has completed. `async-action-state` will have shape: {`::action/status` `::inflight|::success|::error` `::action/action` `<action-map>` `::action/data` `<action-data>` `::action/error` `<action-error>`} - `key` : the action key and the default path in the `state` for the `async-action-state` - `state-bindings` : fn bindings to destructure the global `state` map - `async-action-state-bindings` : fn bindings to destructure the `async-action-state` map - `action-bindings` : fn bindings to destructure the `action` map - `handler-promise-or-async-handler-map` : form returning a promise of the `<action-data>` or a map with shape: {`::a/async` `Promise<action-data>` `::a/navigate`[-*] `<url>` } may refer to any of the destructured bindings
(def-async-action-bindings key
[state-bindings async-action-state-bindings
action-bindings]
handler-promise-or-async-handler-map
handler-fn)
a macro to establish bindings used by other async-action macros.
both def-async-action
and deepstate.action.axios/def-axios-action
defer to this macro to establish bindings
a macro to establish bindings used by other async-action macros. both [[def-async-action]] and [[deepstate.action.axios/def-axios-action]] defer to this macro to establish bindings
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close