MCPcopy Create free account
hub / github.com/bigskysoftware/_hyperscript / run

Method run

www/js/_hyperscript.esm.js:3004–3041  ·  view source on GitHub ↗

* Re-evaluate expression with dependency tracking, compare with last * value, and call handler if changed. Returns false if circular * guard tripped (caller should skip this effect). * @returns {boolean} Whether the effect ran successfully

()

Source from the content-addressed store, hash-verified

3002 * @returns {boolean} Whether the effect ran successfully
3003 */
3004 run() {
3005 this._consecutiveTriggers++;
3006 if (this._consecutiveTriggers > 100) {
3007 console.error(
3008 "Reactivity loop detected: an effect triggered 100 consecutive times without settling. This usually means an effect is modifying a variable it also depends on.",
3009 this.element || this
3010 );
3011 return false;
3012 }
3013 var reactivity2 = this._reactivity;
3014 reactivity2._unsubscribeEffect(this);
3015 var oldDeps = this.dependencies;
3016 this.dependencies = /* @__PURE__ */ new Map();
3017 var prev = reactivity2._currentEffect;
3018 reactivity2._currentEffect = this;
3019 var newValue;
3020 try {
3021 newValue = this.expression();
3022 } catch (e) {
3023 console.error("Error in reactive expression:", e);
3024 this.dependencies = oldDeps;
3025 reactivity2._currentEffect = prev;
3026 reactivity2._subscribeEffect(this);
3027 return true;
3028 }
3029 reactivity2._currentEffect = prev;
3030 reactivity2._subscribeEffect(this);
3031 reactivity2._cleanupOrphanedDeps(oldDeps);
3032 if (!_sameValue(newValue, this._lastValue)) {
3033 this._lastValue = newValue;
3034 try {
3035 this.handler(newValue);
3036 } catch (e) {
3037 console.error("Error in reactive handler:", e);
3038 }
3039 }
3040 return true;
3041 }
3042 /** Reset circular guard after cascade settles. */
3043 resetTriggerCount() {
3044 this._consecutiveTriggers = 0;

Callers 1

_runPendingEffectsMethod · 0.45

Calls 5

_sameValueFunction · 0.70
_unsubscribeEffectMethod · 0.45
_subscribeEffectMethod · 0.45
_cleanupOrphanedDepsMethod · 0.45
handlerMethod · 0.45

Tested by

no test coverage detected