Merge pull request #120 from yoshuawuyts/barracks-8-omg-lol
deps: bump to barracks 8
This commit is contained in:
@@ -15,7 +15,7 @@ const app = choo({
|
||||
console.log(data)
|
||||
console.groupEnd()
|
||||
},
|
||||
onState: function (data, state, prev, createSend) {
|
||||
onStateChange: function (data, state, prev, createSend) {
|
||||
console.groupCollapsed('State')
|
||||
console.log(prev)
|
||||
console.log(state)
|
||||
|
||||
@@ -17,7 +17,7 @@ module.exports = choo
|
||||
function choo (opts) {
|
||||
opts = opts || {}
|
||||
|
||||
const _store = start._store = barracks(xtend(opts, { onState: render }))
|
||||
const _store = start._store = barracks(xtend(opts, { onStateChange: render }))
|
||||
var _router = start._router = null
|
||||
var _defaultRoute = null
|
||||
var _rootNode = null
|
||||
@@ -36,7 +36,7 @@ function choo (opts) {
|
||||
serverState = serverState || {}
|
||||
assert.equal(typeof route, 'string', 'choo.app.toString: route must be a string')
|
||||
assert.equal(typeof serverState, 'object', 'choo.app.toString: serverState must be an object')
|
||||
_store.start({ noSubscriptions: true, noReducers: true, noEffects: true })
|
||||
_store.start({ subscriptions: false, reducers: false, effects: false })
|
||||
|
||||
const state = _store.state({ state: serverState })
|
||||
const router = createRouter(_defaultRoute, _routes, createSend)
|
||||
@@ -81,7 +81,9 @@ function choo (opts) {
|
||||
// update the DOM after every state mutation
|
||||
// (obj, obj, obj, str, fn) -> null
|
||||
function render (data, state, prev, name, createSend) {
|
||||
if (opts.onState) opts.onState(data, state, prev, name, createSend)
|
||||
if (opts.onStateChange) {
|
||||
opts.onStateChange(data, state, prev, name, createSend)
|
||||
}
|
||||
|
||||
const newTree = _router(state.location.pathname, state, prev)
|
||||
_rootNode = yo.update(_rootNode, newTree)
|
||||
@@ -119,7 +121,7 @@ function choo (opts) {
|
||||
return function chooWrap (params, state) {
|
||||
const nwPrev = prev
|
||||
const nwState = prev = xtend(state, { params: params })
|
||||
if (!opts.noFreeze) Object.freeze(nwState)
|
||||
if (opts.freeze !== false) Object.freeze(nwState)
|
||||
return child(nwState, nwPrev, send)
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"barracks": "^7.0.3",
|
||||
"barracks": "^8.0.0",
|
||||
"document-ready": "~1.0.2",
|
||||
"global": "^4.3.0",
|
||||
"hash-match": "^1.0.2",
|
||||
|
||||
@@ -25,7 +25,7 @@ test('freeze (default)', function (t) {
|
||||
|
||||
test('noFreeze', function (t) {
|
||||
t.plan(2)
|
||||
const app = choo({noFreeze: true})
|
||||
const app = choo({freeze: false})
|
||||
|
||||
app.model({
|
||||
state: {
|
||||
|
||||
@@ -18,7 +18,7 @@ test('hooks', function (t) {
|
||||
t.equal(caller, '/', 'onAction: caller name')
|
||||
t.equal(typeof createSend, 'function', 'onAction: createSend fn')
|
||||
},
|
||||
onState: function (action, state, prev, createSend) {
|
||||
onStateChange: function (action, state, prev, createSend) {
|
||||
t.deepEqual(action, {foo: 'bar'}, 'onState: action data')
|
||||
t.deepEqual(state.clicks, 1, 'onState: new state: 1 clicks')
|
||||
t.deepEqual(prev.clicks, 0, 'onState: prev state: 0 clicks')
|
||||
|
||||
Reference in New Issue
Block a user