(action-context-provider & args)
a ContextProvider element to provide an action-context
props:
context
- the action-context
React contextinitial-arg
- the initial state
valuechildren
- only the first child will be included
as a child of the ContextProvider
elementa ContextProvider element to provide an action-context props: - `context` - the `action-context` React context - `initial-arg` - the initial `state` value - `children` - only the first child will be included as a child of the `ContextProvider` element
(create-action-context)
create the React Context
object
create the React `Context` object
(def-action key [state-bindings action-bindings] effects-map)
define a generic action handler
key
: the action keystate-bindings
: fn bindings to destructure the stateaction-bindings
: fn bindings to destructure the actioneffects-map
: a form which evaluates to an action-effects
map.
can use the action-bindings
define a generic action handler - `key` : the action key - `state-bindings` : fn bindings to destructure the state - `action-bindings` : fn bindings to destructure the action - `effects-map` : a form which evaluates to an `action-effects` map. can use the `action-bindings`
(def-state-action key bindings state-effect-map)
define an action handler with only state effects
key
: the action keystate-bindings
: fn bindings to destructure the stateaction-bindings
: fn bindings to destructure the actionstate-effect-map
: a form which evaluates to a state map.
can use the action-bindings
define an action handler with only state effects - `key` : the action key - `state-bindings` : fn bindings to destructure the state - `action-bindings` : fn bindings to destructure the action - `state-effect-map` : a form which evaluates to a state map. can use the `action-bindings`
handle a possibly asynchronous action
macros such as
def-action
, def-state-action
,
deepstate.action.async/def-async-action
and
deepstate.action.axios/def-axios-action
provide
sugar creating implementations of this multimethod
action
: the action
map. must have key ::action
which identifies the handler multimethodreturns:
`action-effects-fn` = (f state) -> `action-effects`
`action-effects` = {::state <state>
::navigate <url>
::dispatch <action-map>|[<action-map>]
::later Promise<action-effects-fn>}
i.e. handle
returns a fn of state
which, when invoked,
returns a map of (all optional) effects, including
::state
- updated state::navigate
- a url to navigate to::dispatch
- further action
maps to dispatch::later
- a Promise of another action-effects
fnhandle a possibly asynchronous action macros such as [[def-action]], [[def-state-action]], [[deepstate.action.async/def-async-action]] and [[deepstate.action.axios/def-axios-action]] provide sugar creating implementations of this multimethod - `action` : the `action` map. must have key `::action` which identifies the handler multimethod returns: ```Clojure `action-effects-fn` = (f state) -> `action-effects` `action-effects` = {::state <state> ::navigate <url> ::dispatch <action-map>|[<action-map>] ::later Promise<action-effects-fn>} ``` i.e. `handle` returns a fn of `state` which, when invoked, returns a map of (all optional) effects, including - `::state` - updated state - `::navigate` - a url to navigate to - `::dispatch` - further `action` maps to dispatch - `::later` - a Promise of another `action-effects` fn
(use-action ctx)
(use-action ctx path)
get a state value and dispatch fn
ctx
- the action contextpath
- optional path into state for returned state valuereturns:
[state
dispatch
]
get a state value and dispatch fn - `ctx` - the action context - `path` - optional path into state for returned state value returns: [`state` `dispatch`]
(use-action-context ctx)
get the value from an action-context
get the value from an `action-context`
(use-action-dispatch ctx)
get a dispatch fn
ctx
- the action contextget a dispatch fn - `ctx` - the action context
(use-action-state ctx)
(use-action-state ctx path)
extract the value at path
(default nil
) in the current state
from an action-context
extract the value at `path` (default `nil`) in the current `state` from an `action-context`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close