|
@@ -1,5 +1,5 @@
|
|
export const createStore = (initial, actions = {}) => {
|
|
export const createStore = (initial, actions = {}) => {
|
|
- const store = {};
|
|
|
|
|
|
+ const store = {}; // maps keys to observables
|
|
const hooks = {};
|
|
const hooks = {};
|
|
|
|
|
|
const mergeState = newState => {
|
|
const mergeState = newState => {
|
|
@@ -10,7 +10,7 @@ export const createStore = (initial, actions = {}) => {
|
|
|
|
|
|
const dispatch = Object.fromEntries(Object.entries(actions).map(([name, action]) => [name, (...args) => mergeState(action(...args))]));
|
|
const dispatch = Object.fromEntries(Object.entries(actions).map(([name, action]) => [name, (...args) => mergeState(action(...args))]));
|
|
|
|
|
|
- const selector = {}; // TODO
|
|
|
|
|
|
+ const selector = Object.fromEntries(Object.entries(store).map(([key, obs]) => [key, obs._get]));
|
|
|
|
|
|
return [hooks, dispatch, selector];
|
|
return [hooks, dispatch, selector];
|
|
}
|
|
}
|