File tree 2 files changed +10
-7
lines changed
2 files changed +10
-7
lines changed Original file line number Diff line number Diff line change @@ -25,13 +25,6 @@ export class Store {
25
25
strict = false
26
26
} = options
27
27
28
- let {
29
- state = { }
30
- } = options
31
- if ( typeof state === 'function' ) {
32
- state = state ( ) || { }
33
- }
34
-
35
28
// store internal state
36
29
this . _committing = false
37
30
this . _actions = Object . create ( null )
@@ -56,6 +49,8 @@ export class Store {
56
49
// strict mode
57
50
this . strict = strict
58
51
52
+ const state = this . _modules . root . state
53
+
59
54
// init root module.
60
55
// this also recursively registers all sub-modules
61
56
// and collects all module getters inside this._wrappedGetters
Original file line number Diff line number Diff line change @@ -286,6 +286,14 @@ describe('Store', () => {
286
286
expect ( store . state . a ) . toBe ( 3 )
287
287
} )
288
288
289
+ it ( 'should not call root state function twice' , ( ) => {
290
+ const spy = jasmine . createSpy ( ) . and . returnValue ( 1 )
291
+ new Vuex . Store ( {
292
+ state : spy
293
+ } )
294
+ expect ( spy ) . toHaveBeenCalledTimes ( 1 )
295
+ } )
296
+
289
297
it ( 'subscribe: should handle subscriptions / unsubscriptions' , ( ) => {
290
298
const subscribeSpy = jasmine . createSpy ( )
291
299
const secondSubscribeSpy = jasmine . createSpy ( )
You can’t perform that action at this time.
0 commit comments