woby
Version:
A high-performance framework with fine-grained observable/signal-based reactivity for building rich applications.
38 lines (37 loc) • 1.02 kB
JavaScript
import { O as Owner, a as OWNER, S as SYMBOL_SUSPENSE, l as lazySetAdd, b as lazySetDelete, c as callStack } from "./setters-Be-jpuHZ.js";
class Root extends Owner {
/* CONSTRUCTOR */
constructor(register) {
super();
this.parent = OWNER;
this.context = OWNER.context;
if (register) {
const suspense = this.get(SYMBOL_SUSPENSE);
if (suspense) {
this.registered = true;
lazySetAdd(this.parent, "roots", this);
}
}
}
/* API */
dispose(deep) {
if (this.registered) {
lazySetDelete(this.parent, "roots", this);
}
super.dispose(deep);
}
wrap(fn, owner, observer, stack) {
const dispose = (disposeStack) => this.dispose(true);
const wrapper = (callStack2) => fn(callStack2, dispose);
return super.wrap(wrapper, this, void 0, stack);
}
}
const root = (fn) => {
const stack = callStack();
return new Root(true).wrap(fn, void 0, void 0, stack);
};
export {
Root as R,
root as r
};
//# sourceMappingURL=root-Cy1I57g_.js.map