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

Method run

www/js/_hyperscript-max.js:3005–3042  ·  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

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