瀏覽代碼

Update path of mergeState, assuming observable definition

Kirk Trombley 5 年之前
父節點
當前提交
508000eb2d
共有 1 個文件被更改,包括 9 次插入2 次删除
  1. 9 2
      client/src/store.js

+ 9 - 2
client/src/store.js

@@ -3,8 +3,15 @@ export const createStore = (initial, actions = {}) => {
   const hooks = {};
 
   const mergeState = newState => {
-    // TODO
-  }
+    Object.entries(newState).forEach(([key, newValue]) => {
+      const obs = store[key];
+      if (obs) {
+        obs._set(newValue);
+      } else {
+        // TODO
+      }
+    });
+  };
 
   mergeState(initial);