Kaynağa Gözat

Selector, assuming observable definition

Kirk Trombley 5 yıl önce
ebeveyn
işleme
f4177f1d3d
1 değiştirilmiş dosya ile 2 ekleme ve 2 silme
  1. 2 2
      client/src/store.js

+ 2 - 2
client/src/store.js

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