Permalink
Browse files

Merge pull request #10 from ktsn/dont-override-init

Stop overriding Vue init function
  • Loading branch information...
ktsn committed Apr 24, 2016
2 parents 843835b + 6630740 commit f0a254ea5c7b330bcc2446167b970940d67a724b
Showing with 9 additions and 17 deletions.
  1. +9 −17 src/connect.js
View
@@ -6,27 +6,19 @@ export function connect(getters, actions) {
if (actions == null) actions = {};
return function(name, Component) {
const container = Vue.extend({
const getterProps = Object.keys(getters).map(bindProp);
const actionProps = Object.keys(actions).map(bindProp);
return Vue.extend({
template: `<${name} ${getterProps.concat(actionProps).join(' ')}></${name}>`,
components: {
[name]: Component
},
vuex: {
getters,
actions
}
});
const _init = container.prototype._init;
container.prototype._init = function(options = {}) {
const getterProps = Object.keys(getters).map(bindProp);
const actionProps = Object.keys(actions).map(bindProp);
options.template = `<${name} ${getterProps.concat(actionProps).join(' ')}></${name}>`;
options.vuex = options.vuex || {};
options.vuex.getters = getters;
options.vuex.actions = actions;
_init.call(this, options);
};
return container;
};
}

0 comments on commit f0a254e

Please sign in to comment.