Comparing version 8.3.2 to 9.0.0
12
index.js
@@ -212,3 +212,3 @@ const mutate = require('xtend/mutable') | ||
if (onActionHooks.length) { | ||
applyHook(onActionHooks, data, _state, name, caller, createSend) | ||
applyHook(onActionHooks, _state, data, name, caller, createSend) | ||
} | ||
@@ -227,10 +227,10 @@ | ||
if (ns) { | ||
const reducedState = _reducers[actionName](data, _state[ns]) | ||
const reducedState = _reducers[actionName](_state[ns], data) | ||
newState[ns] = xtend(_state[ns], reducedState) | ||
} else { | ||
mutate(newState, reducers[actionName](data, _state)) | ||
mutate(newState, reducers[actionName](_state, data)) | ||
} | ||
reducersCalled = true | ||
if (onStateChangeHooks.length) { | ||
applyHook(onStateChangeHooks, data, newState, _state, actionName, createSend) | ||
applyHook(onStateChangeHooks, newState, data, _state, actionName, createSend) | ||
} | ||
@@ -244,4 +244,4 @@ _state = newState | ||
const send = createSend('effect: ' + name) | ||
if (ns) _effects[actionName](data, _state[ns], send, cb) | ||
else _effects[actionName](data, _state, send, cb) | ||
if (ns) _effects[actionName](_state[ns], data, send, cb) | ||
else _effects[actionName](_state, data, send, cb) | ||
effectsCalled = true | ||
@@ -248,0 +248,0 @@ } |
{ | ||
"name": "barracks", | ||
"version": "8.3.2", | ||
"version": "9.0.0", | ||
"description": "Action dispatcher for unidirectional data flows", | ||
@@ -33,3 +33,3 @@ "main": "index.js", | ||
"unassertify": "^2.0.3", | ||
"watch": "^0.19.2" | ||
"watch": "^1.0.0" | ||
}, | ||
@@ -36,0 +36,0 @@ "dependencies": { |
@@ -20,6 +20,6 @@ # barracks | ||
}, | ||
onAction: (data, state, name, caller, createSend) => { | ||
onAction: (state, data, name, caller, createSend) => { | ||
console.log(`data: ${data}`) | ||
}, | ||
onStateChange: (data, state, prev, caller, createSend) => { | ||
onStateChange: (state, data, prev, caller, createSend) => { | ||
console.log(`state: ${prev} -> ${state}`) | ||
@@ -58,5 +58,5 @@ } | ||
`throw` on each error | ||
- __onAction(data, state, name, caller, createSend):__ called when an `action` | ||
- __onAction(state, data, name, caller, createSend):__ called when an `action` | ||
is fired | ||
- __onStateChange(data, state, prev, caller, createSend):__ called after a | ||
- __onStateChange(state, data, prev, caller, createSend):__ called after a | ||
reducer changes the `state`. | ||
@@ -86,5 +86,5 @@ - __wrapSubscriptions(fn):__ wraps a `subscription` to add custom behavior | ||
wrapReducers: function wrapConstructor (reducer) { | ||
return function wrapper (action, state) { | ||
return function wrapper (state, data) { | ||
console.log('golden pony') | ||
return reducer(action, state) | ||
return reducer(state, data) | ||
} | ||
@@ -207,6 +207,6 @@ } | ||
reducers: { | ||
feedPlantcake: (data, state) => { | ||
feedPlantcake: (state, data) => { | ||
return { count: state.count + 1 } | ||
}, | ||
trimBeard: (data, state) => ({ count: state.count - 1 }) | ||
trimBeard: (state, data) => ({ count: state.count - 1 }) | ||
} | ||
@@ -240,3 +240,3 @@ }) | ||
const app = barracks({ | ||
onError: (data, state, prev, send) => send('app:error', data) | ||
onError: (state, data, prev, send) => send('app:error', data) | ||
}) | ||
@@ -247,3 +247,3 @@ | ||
effects: { | ||
error: (data, state, send, done) => { | ||
error: (state, data, send, done) => { | ||
// if doing http calls here be super sure not to get lost | ||
@@ -262,6 +262,6 @@ // in a recursive error handling loop: remember this IS | ||
reducers: { | ||
moreFoo: (data, state) => ({ foo: state.foo + data.count }) | ||
moreFoo: (state, data) => ({ foo: state.foo + data.count }) | ||
} | ||
effects: { | ||
fetch: (data, state, send, done) => { | ||
fetch: (state, data, send, done) => { | ||
http('foobar.com', function (err, res, body) { | ||
@@ -298,3 +298,3 @@ if (err || res.statusCode !== 200) { | ||
effects: { | ||
printWoofs: (data, state) => console.log(data.woof) | ||
printWoofs: (state, data) => console.log(data.woof) | ||
} | ||
@@ -301,0 +301,0 @@ }) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
25363