Tomi Cvetic 7 éve
szülő
commit
0faedaea33
1 módosított fájl, 27 hozzáadás és 0 törlés
  1. 27 0
      src/module/module.js

+ 27 - 0
src/module/module.js

@@ -1,3 +1,30 @@
 class Module {
+  /** e.g. Module userProfile */
+  constructor (name) {
+    this.name = name
+  }
 
+  /** e.g. Upload the avatar file */
+  addAsyncState (name, defaultState, asyncFunction) {
+    if (!this.state) {
+      this.state = {}
+    }
+    this.state[name] = defaultState
+    if (!this.actionCreators) {
+      this.actionCreators = {}
+    }
+    ['start', 'success', 'failure'].forEach(state => {
+      const actionType = `${this.name}_${name}_${state}`.toUpperCase()
+      const actionCreatorName = 
+      this.actionCreators[] = args => {
+        return {
+          type: actionType,
+          ...args
+        }
+      }
+      const reducerLogic = action => {
+        
+      }
+    })
+  }
 }