Liking cljdoc? Tell your friends :D

deepstate.action


action-context-providerclj/smacro

(action-context-provider & args)

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

ActionContextProvidercljs

source

apply-effects-loopcljs

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

create-action-contextcljs

(create-action-context)

create the React Context object

create the React `Context` object
sourceraw docstring

def-actionclj/smacro

(def-action key [action-bindings] & body)

define 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
define 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`
sourceraw docstring

dispatchcljs

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

handlecljsmultimethod

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

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

sig5005cljs

source

use-actioncljs

(use-action ctx)

get the value from an action-context

get the value from an `action-context`
sourceraw docstring

use-action-statecljs

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

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

× close