|
1 | | -import { reactive, computed, watch } from 'vue' |
| 1 | +import { reactive, watch } from 'vue' |
2 | 2 | import { storeKey } from './injectKey' |
3 | 3 | import devtoolPlugin from './plugins/devtool' |
4 | 4 | import ModuleCollection from './module/module-collection' |
@@ -286,15 +286,15 @@ function resetStoreState (store, state, hot) { |
286 | 286 | store._makeLocalGettersCache = Object.create(null) |
287 | 287 | const wrappedGetters = store._wrappedGetters |
288 | 288 | const computedObj = {} |
289 | | - const computedCache = {} |
290 | 289 | forEachValue(wrappedGetters, (fn, key) => { |
291 | 290 | // use computed to leverage its lazy-caching mechanism |
292 | 291 | // direct inline function use will lead to closure preserving oldState. |
293 | 292 | // using partial to return function with only arguments preserved in closure environment. |
294 | 293 | computedObj[key] = partial(fn, store) |
295 | | - computedCache[key] = computed(() => computedObj[key]()) |
296 | 294 | Object.defineProperty(store.getters, key, { |
297 | | - get: () => computedCache[key].value, |
| 295 | + // TODO: use `computed` when it's possible. at the moment we can't due to |
| 296 | + // https://github.com/vuejs/vuex/pull/1883 |
| 297 | + get: () => computedObj[key](), |
298 | 298 | enumerable: true // for local getters |
299 | 299 | }) |
300 | 300 | }) |
|
0 commit comments