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