(async-action-bindings _key
bindings
state
async-action-state
new-async-action-state
action
&
body)
a macro which establishes bindings for async action definitions... both
the action-data-promise
and the effects-map
can use
these bindings to destructure the global state
, the async-action-state
and the action
map
a macro which establishes bindings for async action definitions... both the `action-data-promise` and the `effects-map` can use these bindings to destructure the global `state`, the `async-action-state` and the `action` map
(async-action-handler key
state
action
async-action-data-promise-fn
init-effects-fn
completion-effects-fn)
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 map value being handled
::action/path
- instead of updating the state
at key
,
update the state
at path
async-action-data-promise
: a promise of the action dataeffects-fn
: a (fn <state>) wrapping the effects-map
form,
to be called when the promise completes, returns an effects mapasync-action-state
will be updated at ::action-path
with a map
with these keys:
`::action/status` - `::inflight` | `::success` | `::error`
`::action/action` - the `action` map
`::action/data` - the happy-path result of the `async-action-data-promise`
`::action/error` - any error result of the `async-action-data-promise`
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 map value being handled - `::action/path` - instead of updating the `state` at `key`, update the `state` at `path` - `async-action-data-promise` : a promise of the action data - `effects-fn` : a (fn <state>) wrapping the `effects-map` form, to be called when the promise completes, returns an effects map `async-action-state` will be updated at `::action-path` with a map with these keys: ```Clojure `::action/status` - `::inflight` | `::success` | `::error` `::action/action` - the `action` map `::action/data` - the happy-path result of the `async-action-data-promise` `::action/error` - any error result of the `async-action-data-promise` ```
(def-async-action key
[_state-bindings _async-action-state-bindings _action-bindings
:as bindings]
async-action-data-promise
completion-effects-map)
(def-async-action key
[_state-bindings _async-action-state-bindings _action-bindings
:as bindings]
async-action-data-promise
init-effects-map
completion-effects-map)
a macro which defines 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` `<async-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
mapasync-action-data-promise
: form returning a promise of the
<async-action-data>
- may use any established bindingsinit-effects-map
: form which will be ebaluated before the promise
is createdcompletion-effects-map
: form which will be evaluated when the
async-action-data-promise
completes and
returning action-effects
including ::action/state
,
::action/dispatch
and ::action/navigate
a macro which defines 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: ```Clojure {`::action/status` `::inflight|::success|::error` `::action/action` `<action-map>` `::action/data` `<async-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 - `async-action-data-promise` : form returning a promise of the `<async-action-data>` - may use any established bindings - `init-effects-map` : form which will be ebaluated before the promise is created - `completion-effects-map` : form which will be evaluated when the `async-action-data-promise` completes and returning `action-effects` including `::action/state`, `::action/dispatch` and `::action/navigate`
(def-async-action-handler key
[_state-bindings _async-action-state-bindings
_action-bindings :as bindings]
async-action-data-promise
init-effects-map
completion-effects-map
handler-fn)
a macro which defines a handler for an async action, leaving
particular behaviour to the handler-fn
.
def-async-action
and deepstate.action.axios/def-axios-action
both defer to this macro
key
- the action keybindings
- bindings for the global state
, the async-action-state
and
the action
mapasync-action-data-promise
- a promise of the data for the async actioninit-effects-map
- a form to be evaluated before the promise is
createdcompletion-effects-map
- a form to be evaluated after the
async-action-data-promise
has completedhandler-fn
- the fn implementing specific async action behavioura macro which defines a handler for an async action, leaving particular behaviour to the `handler-fn`. [[def-async-action]] and [[deepstate.action.axios/def-axios-action]] both defer to this macro - `key` - the action key - `bindings` - bindings for the global `state`, the `async-action-state` and the `action` map - `async-action-data-promise` - a promise of the data for the async action - `init-effects-map` - a form to be evaluated before the promise is created - `completion-effects-map` - a form to be evaluated after the `async-action-data-promise` has completed - `handler-fn` - the fn implementing specific async action behaviour
(navigate-always async-action-state url)
(navigate-always effs async-action-state url)
reaction helper - always navigate
reaction helper - always navigate
(navigate-on-error async-action-state url)
(navigate-on-error effs async-action-state url)
reaction helper - navigate only on error
reaction helper - navigate only on error
(navigate-on-inflight async-action-state url)
(navigate-on-inflight effs async-action-state url)
reaction helper - navigate only when inflight
reaction helper - navigate only when inflight
(navigate-on-success async-action-state url)
(navigate-on-success effs async-action-state url)
reaction helper - navigate only on success
reaction helper - navigate only on success
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close