| 93 | } |
| 94 | |
| 95 | setModule(name: string | StoreModule, param?: StoreOptions | StoreModule) { |
| 96 | if (!param) { |
| 97 | param = name as StoreModule; |
| 98 | name = (param as StoreModule).name; |
| 99 | } |
| 100 | |
| 101 | if (param.state) { |
| 102 | const moduleState = |
| 103 | typeof param.state === 'function' ? param.state(this.initStoreState) : param.state; |
| 104 | extend(this.state, moduleState); |
| 105 | } |
| 106 | |
| 107 | if (param.computed) { |
| 108 | forEach(param.computed, (item, key) => { |
| 109 | this.setComputed(key, item); |
| 110 | }); |
| 111 | } |
| 112 | |
| 113 | if (param.watch) { |
| 114 | forEach(param.watch, (item, key) => { |
| 115 | this.setWatch(key, item); |
| 116 | }); |
| 117 | } |
| 118 | |
| 119 | if (param.action) { |
| 120 | forEach(param.action, (item, key) => { |
| 121 | this.setAction(key, item); |
| 122 | }); |
| 123 | } |
| 124 | |
| 125 | if (param.observe) { |
| 126 | forEach(param.observe, (item) => { |
| 127 | this.observe(item); |
| 128 | }); |
| 129 | } |
| 130 | } |
| 131 | |
| 132 | setValue(target: Record<string, any>, key: string, source: Record<string, any>) { |
| 133 | extend(target, { |