|
@@ -1,7 +1,7 @@
|
|
import applyMixin from './mixin'
|
|
import applyMixin from './mixin'
|
|
import devtoolPlugin from './plugins/devtool'
|
|
import devtoolPlugin from './plugins/devtool'
|
|
import ModuleCollection from './module/module-collection'
|
|
import ModuleCollection from './module/module-collection'
|
|
-import { forEachValue, isObject, isPromise, assert } from './util'
|
|
|
|
|
|
+import { forEachValue, isObject, isPromise, assert, partial } from './util'
|
|
|
|
|
|
let Vue // bind on install
|
|
let Vue // bind on install
|
|
|
|
|
|
@@ -256,7 +256,9 @@ function resetStoreVM (store, state, hot) {
|
|
const computed = {}
|
|
const computed = {}
|
|
forEachValue(wrappedGetters, (fn, key) => {
|
|
forEachValue(wrappedGetters, (fn, key) => {
|
|
// use computed to leverage its lazy-caching mechanism
|
|
// use computed to leverage its lazy-caching mechanism
|
|
- computed[key] = () => fn(store)
|
|
|
|
|
|
+ // direct inline function use will lead to closure preserving oldVm.
|
|
|
|
+ // using partial to return function with only arguments preserved in closure enviroment.
|
|
|
|
+ computed[key] = partial(fn, store)
|
|
Object.defineProperty(store.getters, key, {
|
|
Object.defineProperty(store.getters, key, {
|
|
get: () => store._vm[key],
|
|
get: () => store._vm[key],
|
|
enumerable: true // for local getters
|
|
enumerable: true // for local getters
|