Procházet zdrojové kódy

Dispatch, based on mergeState

Kirk Trombley před 5 roky
rodič
revize
36424b58d9
1 změnil soubory, kde provedl 1 přidání a 1 odebrání
  1. 1 1
      client/src/store.js

+ 1 - 1
client/src/store.js

@@ -8,7 +8,7 @@ export const createStore = (initial, actions = {}) => {
 
   mergeState(initial);
 
-  const dispatch = {}; // TODO
+  const dispatch = Object.fromEntries(Object.entries(actions).map(([name, action]) => [name, (...args) => mergeState(action(...args))]));
 
   const selector = {}; // TODO