File tree 1 file changed +40
-0
lines changed
1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ let Vue ;
2
+
3
+ class Store {
4
+ constructor ( ) {
5
+ this . _vm = new Vue ( {
6
+ data : {
7
+ $$state : this . state
8
+ }
9
+ } )
10
+ }
11
+
12
+ commit ( type , payload , _options ) {
13
+ const entry = this . _mutations [ type ] ;
14
+ entry . forEach ( function commitIterator ( handler ) {
15
+ handler ( payload ) ;
16
+ } ) ;
17
+ }
18
+
19
+ dispatch ( type , payload ) {
20
+ const entry = this . _actions [ type ] ;
21
+
22
+ return entry . length > 1
23
+ ? Promise . all ( entry . map ( handler => handler ( payload ) ) )
24
+ : entry [ 0 ] ( payload ) ;
25
+ }
26
+ }
27
+
28
+ function vuexInit ( ) {
29
+ const options = this . $options ;
30
+ if ( options . store ) {
31
+ this . $store = options . store ;
32
+ } else {
33
+ this . $store = options . parent . $store ;
34
+ }
35
+ }
36
+
37
+ export default install ( _Vue ) {
38
+ Vue . mixin ( { beforeCreate : vuexInit } ) ;
39
+ Vue = _Vue ;
40
+ }
You can’t perform that action at this time.
0 commit comments