diff --git a/store.js b/store.js index d3f3a3a5d9..a1d6dc4d2e 100644 --- a/store.js +++ b/store.js @@ -150,25 +150,4 @@ assign(Store.prototype, { } }); -function combineStores(children, store) { - if (!store) store = new Store(); - var updates = {}; - - function addChild(key) { - var child = children[key]; - updates[key] = child.get(); - - child.onchange(function(state) { - var update = {}; - update[key] = state; - store.set(update); - }); - } - - for (var key in children) addChild(key); - - store.set(updates); - return store; -} - -export { Store, combineStores }; \ No newline at end of file +export { Store }; \ No newline at end of file diff --git a/test/store/index.js b/test/store/index.js index 246e655229..25099a9066 100644 --- a/test/store/index.js +++ b/test/store/index.js @@ -1,7 +1,7 @@ import assert from 'assert'; import { Store, combineStores } from '../../store.js'; -describe.only('store', () => { +describe('store', () => { describe('get', () => { it('gets a specific key', () => { const store = new Store({ @@ -143,51 +143,4 @@ describe.only('store', () => { }, /'bar' is a read-only property/); }); }); - - describe('combineStores', () => { - it('merges stores', () => { - const a = new Store({ - x: 1, - y: 2 - }); - - a.compute('z', ['x', 'y'], (x, y) => x + y); - - const b = new Store({ - x: 3, - y: 4 - }); - - b.compute('z', ['x', 'y'], (x, y) => x + y); - - const c = combineStores({ a, b }); - - c.compute('total', ['a', 'b'], (a, b) => a.z + b.z); - - assert.deepEqual(c.get(), { - a: { - x: 1, - y: 2, - z: 3 - }, - b: { - x: 3, - y: 4, - z: 7 - }, - total: 10 - }); - - const values = []; - - c.observe('total', total => { - values.push(total); - }); - - a.set({ x: 2, y: 3 }); - b.set({ x: 5, y: 6 }); - - assert.deepEqual(values, [10, 12, 16]); - }); - }); });