UNPKG

@studiometa/js-toolkit

Version:

A set of useful little bits of JavaScript to boost your project! 🚀

35 lines (34 loc) • 847 B
import { useMutation } from "../services/index.js"; function withMutation(BaseClass, { target = (instance) => instance.$el, ...options } = {}) { class WithMutation extends BaseClass { /** * Config. */ static config = { ...BaseClass.config, emits: ["mutated"] }; /** * Class constructor. */ constructor(element) { super(element); this.$on("mounted", () => { this.$services.register( "mutated", useMutation.bind(void 0, target.call(this, this), options) ); this.$services.enable("mutated"); }); this.$on("destroyed", () => { this.$services.disable("mutated"); this.$services.unregister("mutated"); }); } } return WithMutation; } export { withMutation }; //# sourceMappingURL=withMutation.js.map