Comparing version 8.3.1 to 8.3.2
@@ -143,3 +143,3 @@ const mutate = require('xtend/mutable') | ||
cb(send, function (err) { | ||
applyHook(onErrorHooks, err) | ||
applyHook(onErrorHooks, err, _state, createSend) | ||
}) | ||
@@ -146,0 +146,0 @@ return cb |
{ | ||
"name": "barracks", | ||
"version": "8.3.1", | ||
"version": "8.3.2", | ||
"description": "Action dispatcher for unidirectional data flows", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -64,3 +64,3 @@ # barracks | ||
- __wrapEffects(fn):__ wraps an `effect` to add custom behavior | ||
- __wrapInitialState(fn):__ mutate the initial `state` to add custom | ||
- __wrapInitialState(obj):__ mutate the initial `state` to add custom | ||
behavior - useful to mutate the state before starting up | ||
@@ -74,2 +74,21 @@ | ||
The `wrap*` hooks are synchronously resolved when the `store.start()` method is | ||
called, and the corresponding values from the models are loaded. All wrap hooks | ||
(or wrappers) are passed the argument that would usually be called, so it can | ||
be wrapped or modified. Say we want to make all our `reducers` print `'golden | ||
pony'` every time they're run, we'd do: | ||
```js | ||
const barracks = require('barracks') | ||
const store = barracks() | ||
store.use({ | ||
wrapReducers: function wrapConstructor (reducer) { | ||
return function wrapper (action, state) { | ||
console.log('golden pony') | ||
return reducer(action, state) | ||
} | ||
} | ||
}) | ||
``` | ||
Hooks should be used with care, as they're the most powerful interface into | ||
@@ -313,3 +332,3 @@ the state. For application level code, it's generally recommended to delegate to | ||
- [choo](https://github.com/yoshuawuyts/choo) - sturdy frontend framework | ||
- [sheet-router](https://github.com/yoshuawuyts/wayfarer) - fast, modular | ||
- [sheet-router](https://github.com/yoshuawuyts/sheet-router) - fast, modular | ||
client-side router | ||
@@ -316,0 +335,0 @@ - [yo-yo](https://github.com/maxogden/yo-yo) - template string based view |
25368
356