ez-saga 17.0.1 → 17.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ez-saga",
3
- "version": "17.0.1",
3
+ "version": "17.0.3",
4
4
  "description": "The ez-saga project is a project that imitates dva-js",
5
5
  "main": "src/index.js",
6
6
  "sideEffects": false,
@@ -31,7 +31,7 @@ export interface EffectTool {
31
31
 
32
32
  /** Effect函数类型 */
33
33
  export interface Effect {
34
- (action: PayloadAction, tool: EffectTool): Promise<any>;
34
+ (action: PayloadAction, tool: EffectTool): Generator;
35
35
  }
36
36
 
37
37
  /** ModelReducer定义 */
@@ -47,10 +47,14 @@ export interface ModelEffect {
47
47
 
48
48
  export interface ReduxModel {
49
49
  name: string,
50
- state: any;
50
+ state?: any;
51
+ reducers?: ModelReducer
52
+ effects?: ModelEffect;
53
+ }
54
+
55
+ interface ReduxSagaModel extends ReduxModel {
51
56
  initialState: any,
52
57
  reducers: ModelReducer
53
- effects: ModelEffect;
54
58
  }
55
59
 
56
60
  export interface RegistedModel {
@@ -118,11 +122,14 @@ function getRegistModelFunc(store: Store<any, ReduxAction>, registedModel: Regis
118
122
  * effects: {}
119
123
  * }
120
124
  */
121
- return function regist(model: ReduxModel): void {
125
+ return function regist(reduxModel: ReduxModel): void {
126
+ const model = {
127
+ ...reduxModel,
128
+ initialState: {}
129
+ } as ReduxSagaModel;
122
130
  if (registedModel[model.name]) {
123
131
  return;
124
132
  }
125
- delete model.initialState;
126
133
  if (!model.state) {
127
134
  model.state = {};
128
135
  }