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

Method createEffect

www/js/_hyperscript.js:3498–3514  ·  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

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

Callers 8

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

Calls 2

initializeMethod · 0.95
stopMethod · 0.95

Tested by

no test coverage detected