Explorar el Código

Dispatch, based on mergeState

Kirk Trombley hace 5 años
padre
commit
36424b58d9
Se han modificado 1 ficheros con 1 adiciones y 1 borrados
  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