Skip to content

Commit

Permalink
Merge pull request #10 from ktsn/dont-override-init
Browse files Browse the repository at this point in the history
Stop overriding Vue init function
  • Loading branch information
ktsn committed Apr 24, 2016
2 parents 843835b + 6630740 commit f0a254e
Showing 1 changed file with 9 additions and 17 deletions.
26 changes: 9 additions & 17 deletions src/connect.js
Expand Up @@ -6,27 +6,19 @@ export function connect(getters, actions) {
if (actions == null) actions = {}; if (actions == null) actions = {};


return function(name, Component) { 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: { components: {
[name]: Component [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;
}; };
} }


Expand Down

0 comments on commit f0a254e

Please sign in to comment.