Skip to content

Commit

Permalink
wrap-handlers: add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshuawuyts committed Jul 18, 2016
1 parent b381a97 commit 2468c4a
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,17 +51,26 @@ Handlers can be:
`action` is fired.
- __onStateChange(data, state, prev, caller, createSend):__ called after a reducer
changes the `state`.
- __wrapSubscriptions(fn):__ wraps a `subscription` to add custom behavior
- __wrapReducers(fn):__ wraps a `reducer` to add custom behavior
- __wrapEffects(fn):__ wraps an `effect` to add custom behavior
- __wrapInitialState(fn):__ wraps the combined initial `state` to add custom
behavior - useful to mutate the state before starting up

`createSend()` is a special function that allows the creation of a new named
`send()` function. The first argument should be a string which is the name, the
second argument is a boolean `callOnError` which can be set to `true` to call
the `onError` hook istead of a provided callback. It then returns a
`send(actionName, data?)` function.

Handlers should be used with care, as they're the most powerful interface into
the state. For application level code it's generally recommended to delegate to
actions inside models using the `send()` call, and only shape the actions
inside the handlers.
Store-level handlers (`on*`) should be used with care, as they're the most
powerful interface into the state. For application level code it's generally
recommended to delegate to actions inside models using the `send()` call, and
only shape the actions inside the handlers.

Wrappers (`wrap*`) are useful to extend or even completely override how
`barracks` handlers. For example new asynchronous models (such as `pull-stream`
or `xstream`) can be applied or the way objects are diffed can be changed.

### store.model()
Register a new model on the store. Models are optionally namespaced objects
Expand Down

0 comments on commit 2468c4a

Please sign in to comment.