11import { getWatcher , getDep } from './util'
22
33export default function ( Vue ) {
4- // override init and inject vuex init procedure
5- const _init = Vue . prototype . _init
6- Vue . prototype . _init = function ( options = { } ) {
7- options . init = options . init
8- ? [ vuexInit ] . concat ( options . init )
9- : vuexInit
10- _init . call ( this , options )
11- }
4+ Vue . mixin ( { init } )
125
136 /**
147 * Vuex init hook, injected into each instances init hooks list.
158 */
169
17- function vuexInit ( ) {
10+ function init ( ) {
1811 const options = this . $options
1912 const { store, vuex } = options
2013 // store injection
@@ -31,7 +24,8 @@ export default function (Vue) {
3124 'provide the store option in your root component.'
3225 )
3326 }
34- let { state, getters, actions } = vuex
27+ const { state, actions } = vuex
28+ let { getters } = vuex
3529 // handle deprecated state option
3630 if ( state && ! getters ) {
3731 console . warn (
@@ -43,14 +37,14 @@ export default function (Vue) {
4337 // getters
4438 if ( getters ) {
4539 options . computed = options . computed || { }
46- for ( let key in getters ) {
40+ for ( const key in getters ) {
4741 defineVuexGetter ( this , key , getters [ key ] )
4842 }
4943 }
5044 // actions
5145 if ( actions ) {
5246 options . methods = options . methods || { }
53- for ( let key in actions ) {
47+ for ( const key in actions ) {
5448 options . methods [ key ] = makeBoundAction ( this . $store , actions [ key ] , key )
5549 }
5650 }
@@ -109,7 +103,7 @@ export default function (Vue) {
109103 const Dep = getDep ( vm )
110104 const watcher = new Watcher (
111105 vm ,
112- state => getter ( state ) ,
106+ vm => getter ( vm . state ) ,
113107 null ,
114108 { lazy : true }
115109 )
0 commit comments