浏览代码

changed module

Tomi Cvetic 7 年之前
父节点
当前提交
0faedaea33
共有 1 个文件被更改,包括 27 次插入0 次删除
  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 => {
+        
+      }
+    })
+  }
 }