Skip to content

Commit c052099

Browse files
committed
Fixed issue#1507 : Memory leak happening while using registerModule/unregisterModule.
1 parent 31e4fbc commit c052099

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/store.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import applyMixin from './mixin'
22
import devtoolPlugin from './plugins/devtool'
33
import ModuleCollection from './module/module-collection'
4-
import { forEachValue, isObject, isPromise, assert } from './util'
4+
import { forEachValue, isObject, isPromise, assert, partial } from './util'
55

66
let Vue // bind on install
77

@@ -256,7 +256,7 @@ function resetStoreVM (store, state, hot) {
256256
const computed = {}
257257
forEachValue(wrappedGetters, (fn, key) => {
258258
// use computed to leverage its lazy-caching mechanism
259-
computed[key] = () => fn(store)
259+
computed[key] = partial(fn, store)
260260
Object.defineProperty(store.getters, key, {
261261
get: () => store._vm[key],
262262
enumerable: true // for local getters

src/util.js

+6
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,9 @@ export function isPromise (val) {
6464
export function assert (condition, msg) {
6565
if (!condition) throw new Error(`[vuex] ${msg}`)
6666
}
67+
68+
export function partial (fn, ...bindargs) {
69+
return function (...callargs) {
70+
return fn(...bindargs, ...callargs)
71+
}
72+
}

0 commit comments

Comments
 (0)