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

Method initialize

www/js/_hyperscript.esm.js:2979–2997  ·  view source on GitHub ↗

* First evaluation: track deps, subscribe, call handler if non-null. * Both undefined and null are treated as "no value yet" to support * left-side-wins initialization in bind.

()

Source from the content-addressed store, hash-verified

2977 * left-side-wins initialization in bind.
2978 */
2979 initialize() {
2980 var reactivity2 = this._reactivity;
2981 var prev = reactivity2._currentEffect;
2982 reactivity2._currentEffect = this;
2983 try {
2984 this._lastValue = this.expression();
2985 } catch (e) {
2986 console.error("Error in reactive expression:", e);
2987 }
2988 reactivity2._currentEffect = prev;
2989 reactivity2._subscribeEffect(this);
2990 if (this._lastValue != null) {
2991 try {
2992 this.handler(this._lastValue);
2993 } catch (e) {
2994 console.error("Error in reactive handler:", e);
2995 }
2996 }
2997 }
2998 /**
2999 * Re-evaluate expression with dependency tracking, compare with last
3000 * value, and call handler if changed. Returns false if circular

Callers

nothing calls this directly

Calls 2

_subscribeEffectMethod · 0.45
handlerMethod · 0.45

Tested by

no test coverage detected