MCPcopy Index your code
hub / github.com/bigskysoftware/_hyperscript / createEffect

Method createEffect

www/js/_hyperscript.esm.js:3496–3512  ·  view source on GitHub ↗

* Create a reactive effect with automatic dependency tracking. * @param {() => any} expression - The watched expression * @param {(value: any) => void} handler - Called when the value changes * @param {Object} [options] * @param {Element} [options.element] - Auto-stop when element discon

(expression, handler, options)

Source from the content-addressed store, hash-verified

3494 * @returns {() => void} Stop function
3495 */
3496 createEffect(expression, handler, options) {
3497 var effect = new Effect(
3498 expression,
3499 handler,
3500 options && options.element || null,
3501 this
3502 );
3503 effect.initialize();
3504 if (effect.element) {
3505 var data = effect.element._hyperscript ??= {};
3506 data.effects ??= /* @__PURE__ */ new Set();
3507 data.effects.add(effect);
3508 }
3509 return function() {
3510 effect.stop();
3511 };
3512 }
3513 /** Stop all reactive effects owned by an element. */
3514 stopElementEffects(element) {
3515 var data = element._hyperscript;

Callers 4

installMethod · 0.45
_bindFunction · 0.45
installMethod · 0.45
setupEffectFunction · 0.45

Calls 2

initializeMethod · 0.95
stopMethod · 0.95

Tested by

no test coverage detected