Skip to content

Commit

Permalink
support 1.x as well
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 23, 2016
1 parent b25b4d4 commit 6c1e48a
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/override.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
import { getWatcher, getDep } from './util'

export default function (Vue) {
Vue.mixin({ init })
var version = Number(Vue.version.split('.')[0])

if (version >= 2) {
Vue.mixin({
init: vuexInit
})
} else {
// override init and inject vuex init procedure
// for 1.x backwards compatibility.
const _init = Vue.prototype._init
Vue.prototype._init = function (options = {}) {
options.init = options.init
? [vuexInit].concat(options.init)
: vuexInit
_init.call(this, options)
}
}

/**
* Vuex init hook, injected into each instances init hooks list.
*/

function init () {
function vuexInit () {
const options = this.$options
const { store, vuex } = options
// store injection
Expand Down

0 comments on commit 6c1e48a

Please sign in to comment.