(action-context-provider & args)uses a use-reducer hook to encapsulate state and propagates
it with a ContextProvider
context - the action-context React contextinitial-arg - the initial state valuechild - content to include inside the ContextProvider elementuses a `use-reducer` hook to encapsulate state and propagates it with a `ContextProvider` - `context` - the `action-context` React context - `initial-arg` - the initial `state` value - `child` - content to include inside the `ContextProvider` element
(apply-effects-loop {react-dispatch :deepstate.action/dispatch
:as action-context-val}
update-spec)given an update-spec from a (handle action), apply ActionEffects, looping until all promises are resolved
3 effects are currently supported ...
::update-now - a fn to apply to state to update it
::navigate - a fn to apply to state to get a url to navigate to
::update-later - a promise of further effects, possibly recursive
given an update-spec from a (handle action), apply ActionEffects, looping until all promises are resolved 3 effects are currently supported ... `::update-now` - a fn to apply to `state` to update it `::navigate` - a fn to apply to `state` to get a url to navigate to `::update-later` - a promise of further effects, possibly recursive
(create-action-context)create the React Context object
create the React `Context` object
(def-action key [action-bindings] & body)define a generic action
key : the action keyaction-bindings : fn bindings to destructure the actionbody : any forms which return an action handle ActionEffects
or a promise thereof. can use the action-bindingsdefine a generic action
- `key` : the action key
- `action-bindings` : fn bindings to destructure the action
- `body` : any forms which return an action `handle` ActionEffects
or a promise thereof. can use the `action-bindings`(dispatch action-context-val action)dispatch an action to update the state
action-context-val : the value from an action-context
provided by action-context-provider
action : the action. must have key ::action which
identifies the handler multimethod. if the action
is just a keyword it will be treated as the
::action key
dispatch an action to update the state
- `action-context-val` : the value from an action-context
provided by `action-context-provider`
- `action` : the action. must have key `::action` which
identifies the handler multimethod. if the action
is just a keyword it will be treated as the
`::action` keyhandle a possibly asynchronous action
action : the action. must have key ::action
which identifies the handler multimethodreturns: ActionEffects = (f state) | Promise<(f <state>)> | {::update-now (f state) ::navigate (f state) ::update-later Promise<ActionEffects>}
i.e. handle returns fns of state which will be used to update the state. If the action is asynchronous it can return one fn to update the state now and return another when action has completed, potentially recursively
handle a possibly asynchronous action
- `action` : the action. must have key `::action`
which identifies the handler multimethod
returns:
ActionEffects = (f state) |
Promise<(f <state>)> |
{::update-now (f state)
::navigate (f state)
::update-later Promise<ActionEffects>}
i.e. handle returns fns of state which will be used
to update the state. If the action is asynchronous it
can return one fn to update the state now and return
another when action has completed, potentially
recursively(use-action ctx)get the value from an action-context
get the value from an `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 builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |