|
@@ -1,3 +1,30 @@
|
|
|
class Module {
|
|
|
+
|
|
|
+ constructor (name) {
|
|
|
+ this.name = name
|
|
|
+ }
|
|
|
|
|
|
+
|
|
|
+ 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 => {
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
}
|