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

Method _subscribeEffect

tools/common/_hyperscript.iife.js:3176–3199  ·  view source on GitHub ↗

* Subscribe an effect to all its current deps. * Symbols go into subscription maps, attributes get MutationObservers, * properties use persistent per-element input/change listeners. * @param {Effect} effect

(effect)

Source from the content-addressed store, hash-verified

3174 * @param {Effect} effect
3175 */
3176 _subscribeEffect(effect) {
3177 var reactivity2 = this;
3178 for (var [depKey, dep] of effect.dependencies) {
3179 if (dep.type === "symbol" && dep.scope === "global") {
3180 if (!reactivity2._globalSubscriptions.has(dep.name)) {
3181 reactivity2._globalSubscriptions.set(dep.name, /* @__PURE__ */ new Set());
3182 }
3183 reactivity2._globalSubscriptions.get(dep.name).add(effect);
3184 } else if (dep.type === "symbol" && dep.scope === "element") {
3185 var state = reactivity2._getObjectState(dep.element);
3186 if (!state.subscriptions) {
3187 state.subscriptions = /* @__PURE__ */ new Map();
3188 }
3189 if (!state.subscriptions.has(dep.name)) {
3190 state.subscriptions.set(dep.name, /* @__PURE__ */ new Set());
3191 }
3192 state.subscriptions.get(dep.name).add(effect);
3193 } else if (dep.type === "attribute") {
3194 reactivity2._subscribeAttributeDependency(dep.element, dep.name, effect);
3195 } else if (dep.type === "property") {
3196 reactivity2._subscribePropertyDependency(dep.object, dep.name, effect);
3197 }
3198 }
3199 }
3200 /**
3201 * Subscribe to a DOM attribute. Sets up a persistent MutationObserver
3202 * per element+attribute, shared across effects and re-runs.

Callers 2

initializeMethod · 0.45
runMethod · 0.45

Calls 5

setMethod · 0.45
getMethod · 0.45
_getObjectStateMethod · 0.45

Tested by

no test coverage detected