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

Method createEffect

tools/common/_hyperscript.iife.js:3338–3354  ·  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

3336 * @returns {() => void} Stop function
3337 */
3338 createEffect(expression, handler, options) {
3339 var effect = new Effect(
3340 expression,
3341 handler,
3342 options && options.element || null,
3343 this
3344 );
3345 effect.initialize();
3346 if (effect.element) {
3347 var data = effect.element._hyperscript ??= {};
3348 data.effects ??= /* @__PURE__ */ new Set();
3349 data.effects.add(effect);
3350 }
3351 return function() {
3352 effect.stop();
3353 };
3354 }
3355 /** Stop all reactive effects owned by an element. */
3356 stopElementEffects(element) {
3357 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