@mpxjs/store 2.8.28-beta.11 → 2.8.50

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.
Files changed (2) hide show
  1. package/package.json +4 -4
  2. package/src/index.js +24 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mpxjs/store",
3
- "version": "2.8.28-beta.11",
3
+ "version": "2.8.50",
4
4
  "description": "A store for mpx framework",
5
5
  "main": "src/index.js",
6
6
  "types": "@types/index.d.ts",
@@ -16,7 +16,7 @@
16
16
  "store"
17
17
  ],
18
18
  "author": "donghongping",
19
- "license": "Apache-2.0",
19
+ "license": "ISC",
20
20
  "bugs": {
21
21
  "url": "https://github.com/didi/mpx/issues"
22
22
  },
@@ -26,10 +26,10 @@
26
26
  },
27
27
  "homepage": "https://github.com/didi/mpx#readme",
28
28
  "dependencies": {
29
- "@mpxjs/utils": "^2.8.28-beta.11"
29
+ "@mpxjs/utils": "^2.8.50"
30
30
  },
31
31
  "peerDependencies": {
32
32
  "@mpxjs/core": "^2.8.0"
33
33
  },
34
- "gitHead": "8c7fa579da9c3e71908eb9bfb5833a7d9477505d"
34
+ "gitHead": "32f30631cc5f37503fb7791cb3b0d6c901ee2b27"
35
35
  }
package/src/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import Mpx, { reactive, computed } from '@mpxjs/core'
1
+ import Mpx, { reactive, computed, effectScope } from '@mpxjs/core'
2
2
  import {
3
3
  getByPath,
4
4
  warn,
@@ -115,6 +115,7 @@ class Store {
115
115
  this.mutations = {}
116
116
  this.actions = {}
117
117
  this._subscribers = []
118
+ this._scope = effectScope(true)
118
119
  this.state = this.registerModule(options).state
119
120
  this.resetStoreVM()
120
121
  Object.assign(this, mapStore(this))
@@ -178,26 +179,28 @@ class Store {
178
179
  }
179
180
 
180
181
  resetStoreVM () {
181
- if (__mpx_mode__ === 'web') {
182
- const Vue = Mpx.__vue
183
- const vm = new Vue({
184
- data: {
185
- __mpxState: this.state
186
- },
187
- computed: this.__wrappedGetters
188
- })
189
- const computedKeys = Object.keys(this.__wrappedGetters)
190
- proxy(this.getters, vm, computedKeys)
191
- proxy(this.getters, this.__depsGetters)
192
- } else {
193
- reactive(this.state)
194
- const computedObj = {}
195
- Object.entries(this.__wrappedGetters).forEach(([key, value]) => {
196
- computedObj[key] = computed(value)
197
- })
198
- proxy(this.getters, computedObj)
199
- proxy(this.getters, this.__depsGetters)
200
- }
182
+ this._scope.run(() => {
183
+ if (__mpx_mode__ === 'web') {
184
+ const Vue = Mpx.__vue
185
+ const vm = new Vue({
186
+ data: {
187
+ __mpxState: this.state
188
+ },
189
+ computed: this.__wrappedGetters
190
+ })
191
+ const computedKeys = Object.keys(this.__wrappedGetters)
192
+ proxy(this.getters, vm, computedKeys)
193
+ proxy(this.getters, this.__depsGetters)
194
+ } else {
195
+ reactive(this.state)
196
+ const computedObj = {}
197
+ Object.entries(this.__wrappedGetters).forEach(([key, value]) => {
198
+ computedObj[key] = computed(value)
199
+ })
200
+ proxy(this.getters, computedObj)
201
+ proxy(this.getters, this.__depsGetters)
202
+ }
203
+ })
201
204
  }
202
205
  }
203
206