UNPKG

vue-tdweb

Version:

Documentation is coming.

42 lines 1.53 kB
export function installMixin(Vue) { Vue.mixin({ beforeCreate: function () { var options = this.$options; var optionValue = options.tdProvider; if (optionValue) { this.$_tdProvider = typeof optionValue === 'function' ? optionValue() : optionValue; } else if (options.parent && options.parent.$_tdProvider) { this.$_tdProvider = options.parent.$_tdProvider; } }, created: function () { var _this = this; var tdProvider = this.$_tdProvider; if (this.$_tdSubscriptions || !tdProvider) { return; } this.$_tdSubscriptions = []; // Prepare properties var handlers = this.$options.td; if (handlers && !this.$isServer) { Object.keys(handlers).forEach(function (name) { if (name.charAt(0) !== '$') { _this.$_tdSubscriptions.push(tdProvider.on(name, handlers[name])); } }); } }, destroyed: function () { if (this.$_td) { this.$_td._destroy(); delete this.$_td; } if (this.$_tdSubscriptions) { this.$_tdSubscriptions.forEach(function (unsubscribe) { return unsubscribe(); }); delete this.$_tdSubscriptions; } } }); } //# sourceMappingURL=mixin.js.map