@@ -51,9 +51,9 @@ export class Store {
51
51
// and collects all module getters inside this._wrappedGetters
52
52
installModule ( this , state , [ ] , this . _modules . root )
53
53
54
- // initialize the store vm , which is responsible for the reactivity
54
+ // initialize the store state , which is responsible for the reactivity
55
55
// (also registers _wrappedGetters as computed properties)
56
- resetStoreVM ( this , state )
56
+ resetStoreState ( this , state )
57
57
58
58
// apply plugins
59
59
plugins . forEach ( plugin => plugin ( this ) )
@@ -69,7 +69,7 @@ export class Store {
69
69
}
70
70
71
71
get state ( ) {
72
- return this . _vm . _data . $$state
72
+ return this . _state . data
73
73
}
74
74
75
75
set state ( v ) {
@@ -180,7 +180,7 @@ export class Store {
180
180
181
181
replaceState ( state ) {
182
182
this . _withCommit ( ( ) => {
183
- this . _vm . _data . $$state = state
183
+ this . _state . data = state
184
184
} )
185
185
}
186
186
@@ -195,7 +195,7 @@ export class Store {
195
195
this . _modules . register ( path , rawModule )
196
196
installModule ( this , this . state , path , this . _modules . get ( path ) , options . preserveState )
197
197
// reset store to update getters...
198
- resetStoreVM ( this , this . state )
198
+ resetStoreState ( this , this . state )
199
199
}
200
200
201
201
unregisterModule ( path ) {
@@ -246,12 +246,12 @@ function resetStore (store, hot) {
246
246
const state = store . state
247
247
// init all modules
248
248
installModule ( store , state , [ ] , store . _modules . root , true )
249
- // reset vm
250
- resetStoreVM ( store , state , hot )
249
+ // reset state
250
+ resetStoreState ( store , state , hot )
251
251
}
252
252
253
- function resetStoreVM ( store , state , hot ) {
254
- const oldVm = store . _vm
253
+ function resetStoreState ( store , state , hot ) {
254
+ const oldState = store . _state
255
255
256
256
// bind store public getters
257
257
store . getters = { }
@@ -277,23 +277,21 @@ function resetStoreVM (store, state, hot) {
277
277
//
278
278
// New impl with reactive. Defining redundunt keys to make it as close as
279
279
// the old impl api.
280
- store . _vm = reactive ( {
281
- _data : {
282
- $$state : state
283
- }
280
+ store . _state = reactive ( {
281
+ data : state
284
282
} )
285
283
286
- // enable strict mode for new vm
284
+ // enable strict mode for new state
287
285
if ( store . strict ) {
288
286
enableStrictMode ( store )
289
287
}
290
288
291
- if ( oldVm ) {
289
+ if ( oldState ) {
292
290
if ( hot ) {
293
291
// dispatch changes in all subscribed watchers
294
292
// to force getter re-evaluation for hot reloading.
295
293
store . _withCommit ( ( ) => {
296
- oldVm . _data . $$state = null
294
+ oldState . data = null
297
295
} )
298
296
}
299
297
// TODO: I think we don't need this anymore since we're not using vm?
@@ -394,7 +392,7 @@ function makeLocalContext (store, namespace, path) {
394
392
}
395
393
396
394
// getters and state object must be gotten lazily
397
- // because they will be changed by vm update
395
+ // because they will be changed by state update
398
396
Object . defineProperties ( local , {
399
397
getters : {
400
398
get : noNamespace
@@ -484,7 +482,7 @@ function registerGetter (store, type, rawGetter, local) {
484
482
}
485
483
486
484
function enableStrictMode ( store ) {
487
- watch ( ( ) => store . _vm . _data . $$state , ( ) => {
485
+ watch ( ( ) => store . _state . data , ( ) => {
488
486
if ( process . env . NODE_ENV !== 'production' ) {
489
487
assert ( store . _committing , `do not mutate vuex store state outside mutation handlers.` )
490
488
}
0 commit comments