Liking cljdoc? Tell your friends :D

deepstate.action


def-actioncljsmacro

(def-action key [state-bindings action-bindings] effects-map)

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

def-state-actioncljsmacro

(def-state-action key bindings state-effect-map)

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

handlecljsmultimethod

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 multimethod

returns:

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

use-actioncljs

(use-action)
(use-action initial-state)

get a state value and dispatch fn to interact with state

  • initial-state : initial value of state

returns: [state dispatch]

get a `state` value and `dispatch` fn to interact with state

- `initial-state` : initial value of `state`

returns:
  [`state` `dispatch`]
sourceraw docstring

use-action-contextcljs

(use-action-context ctx)
(use-action-context ctx state-path)

use a [state dispatch] provided in a react context

  • ctx - the react context
  • state-path - optional path to retrieve from state

returns: [state dispatch]

use a [`state` `dispatch`] provided in a react context

- `ctx` - the react context
- `state-path` - optional path to retrieve from state

returns: [`state` `dispatch`]
sourceraw docstring

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

× close