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

Method createEffect

www/js/_hyperscript-max.js:3497–3513  ·  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 elemen

(expression, handler, options)

Source from the content-addressed store, hash-verified

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

Callers 5

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

Calls 2

initializeMethod · 0.95
stopMethod · 0.95

Tested by

no test coverage detected