@benev/slate
Version:
frontend web stuff
27 lines • 1.14 kB
JavaScript
import { ShadowElement } from "../../element/gold.js";
import { usekey } from "../parts/use/parts/utils/usekey.js";
import { UseShadowComponent } from "../parts/use/tailored.js";
import { setup_reactivity } from "../parts/setup_reactivity.js";
export const prepare_shadow_component = ((shell) => (renderer) => class extends ShadowElement {
#use = new UseShadowComponent(this, this.root, () => void this.requestUpdate(), shell.context);
#rend = this.#use[usekey].wrap(() => renderer(this.#use));
#reactivity;
render() {
this.updateComplete.then(() => this.#use[usekey].afterRender());
return this.#reactivity?.render();
}
connectedCallback() {
super.connectedCallback();
this.#use[usekey].reconnect();
this.#reactivity = setup_reactivity(this.#rend, () => void this.requestUpdate());
}
disconnectedCallback() {
super.disconnectedCallback();
this.#use[usekey].disconnect();
if (this.#reactivity) {
this.#reactivity.stop();
this.#reactivity = undefined;
}
}
});
//# sourceMappingURL=shadow_component.js.map