From 9bc8732f1bc8692bf9aa6458ed13354763ff2147 Mon Sep 17 00:00:00 2001 From: Josh Perez Date: Wed, 27 May 2015 17:54:08 -0700 Subject: [PATCH] Revert "Fix recycling values that are not set" This reverts commit 1f8da1b0d7473b7751365eec7de423e6ceb5f7e8. --- src/alt/utils/StateFunctions.js | 8 ++++---- test/recycle-test.js | 29 ----------------------------- 2 files changed, 4 insertions(+), 33 deletions(-) delete mode 100644 test/recycle-test.js diff --git a/src/alt/utils/StateFunctions.js b/src/alt/utils/StateFunctions.js index e5871be6..9eba0e6f 100644 --- a/src/alt/utils/StateFunctions.js +++ b/src/alt/utils/StateFunctions.js @@ -7,10 +7,10 @@ export function setAppState(instance, data, onStore) { const store = instance.stores[key] if (store) { const { config } = store.StoreModel - const state = store[Sym.STATE_CONTAINER] - if (config.onDeserialize) obj[key] = config.onDeserialize(value) || value - fn.eachObject(k => delete state[k], [state]) - fn.assign(state, obj[key]) + if (config.onDeserialize) { + obj[key] = config.onDeserialize(value) || value + } + fn.assign(store[Sym.STATE_CONTAINER], obj[key]) onStore(store) } }, [obj]) diff --git a/test/recycle-test.js b/test/recycle-test.js deleted file mode 100644 index 2d5fcd79..00000000 --- a/test/recycle-test.js +++ /dev/null @@ -1,29 +0,0 @@ -import { assert } from 'chai' -import Alt from '../' -import sinon from 'sinon' - -export default { - 'Recycling': { - 'recycles a store with no initial state'() { - const alt = new Alt() - const actions = alt.generateActions('fire') - - const store = alt.createStore(function () { - this.bindAction(actions.fire, () => { - this.test = (this.test || 0) + 1 - }) - }, 'Store') - - - assert(Object.keys(store.getState()).length === 0, 'store has no state') - actions.fire() - - assert(store.getState().test === 1, 'store has some state') - - alt.recycle() - - assert(Object.keys(store.getState()).length === 0, 'store was emptied') - assert.isUndefined(store.getState().test, 'store was recycled to initial state') - }, - } -}