Skip to content

Commit d5d1ecc

Browse files
committed
remove combineStores
1 parent 96eac06 commit d5d1ecc

File tree

2 files changed

+2
-70
lines changed

2 files changed

+2
-70
lines changed

store.js

+1-22
Original file line numberDiff line numberDiff line change
@@ -150,25 +150,4 @@ assign(Store.prototype, {
150150
}
151151
});
152152

153-
function combineStores(children, store) {
154-
if (!store) store = new Store();
155-
var updates = {};
156-
157-
function addChild(key) {
158-
var child = children[key];
159-
updates[key] = child.get();
160-
161-
child.onchange(function(state) {
162-
var update = {};
163-
update[key] = state;
164-
store.set(update);
165-
});
166-
}
167-
168-
for (var key in children) addChild(key);
169-
170-
store.set(updates);
171-
return store;
172-
}
173-
174-
export { Store, combineStores };
153+
export { Store };

test/store/index.js

+1-48
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import assert from 'assert';
22
import { Store, combineStores } from '../../store.js';
33

4-
describe.only('store', () => {
4+
describe('store', () => {
55
describe('get', () => {
66
it('gets a specific key', () => {
77
const store = new Store({
@@ -143,51 +143,4 @@ describe.only('store', () => {
143143
}, /'bar' is a read-only property/);
144144
});
145145
});
146-
147-
describe('combineStores', () => {
148-
it('merges stores', () => {
149-
const a = new Store({
150-
x: 1,
151-
y: 2
152-
});
153-
154-
a.compute('z', ['x', 'y'], (x, y) => x + y);
155-
156-
const b = new Store({
157-
x: 3,
158-
y: 4
159-
});
160-
161-
b.compute('z', ['x', 'y'], (x, y) => x + y);
162-
163-
const c = combineStores({ a, b });
164-
165-
c.compute('total', ['a', 'b'], (a, b) => a.z + b.z);
166-
167-
assert.deepEqual(c.get(), {
168-
a: {
169-
x: 1,
170-
y: 2,
171-
z: 3
172-
},
173-
b: {
174-
x: 3,
175-
y: 4,
176-
z: 7
177-
},
178-
total: 10
179-
});
180-
181-
const values = [];
182-
183-
c.observe('total', total => {
184-
values.push(total);
185-
});
186-
187-
a.set({ x: 2, y: 3 });
188-
b.set({ x: 5, y: 6 });
189-
190-
assert.deepEqual(values, [10, 12, 16]);
191-
});
192-
});
193146
});

0 commit comments

Comments
 (0)