stencil-quantum
Version:
Experience the quantum realm of stencil.
50 lines (47 loc) • 1.56 kB
JavaScript
import { r as registerInstance, c as createEvent, h, g as getElement } from './index-44d29459.js';
import { P as Provider, t as throwQuantum } from './entanglement-f742a30d.js';
const QuantumProvider = class {
constructor(hostRef) {
registerInstance(this, hostRef);
this.update = createEvent(this, "update", 7);
}
componentWillLoad() {
var _a, _b, _c, _d, _e, _f;
try {
this.name = (_c = (_b = (_a = this.bind) === null || _a === void 0 ? void 0 : _a.name) !== null && _b !== void 0 ? _b : this.name) !== null && _c !== void 0 ? _c : "";
this.namespace = (_e = (_d = this.bind) === null || _d === void 0 ? void 0 : _d.namespace) !== null && _e !== void 0 ? _e : this.namespace;
this.debug = ((_f = this.bind) === null || _f === void 0 ? void 0 : _f.debug) || this.debug;
this.provider = Provider.create(this.el, this.name, this.value, this.namespace, this.debug);
this.provider.listen(val => {
try {
this.update.emit({
value: val,
provider: this.provider
});
}
catch (err) {
throwQuantum(this.el, err);
}
}, true);
}
catch (err) {
throwQuantum(this.el, err);
}
}
onValue(val) {
try {
this.provider.provide(val);
}
catch (err) {
throwQuantum(this.el, err);
}
}
render() {
return h("slot", null);
}
get el() { return getElement(this); }
static get watchers() { return {
"value": ["onValue"]
}; }
};
export { QuantumProvider as quantum_provider };