MCPcopy
hub / github.com/stackblitz/alien-signals / propagate

Function propagate

src/system.ts:118–174  ·  view source on GitHub ↗
(link: Link, innerWrite: boolean)

Source from the content-addressed store, hash-verified

116 }
117
118 function propagate(link: Link, innerWrite: boolean): void {
119 let next = link.nextSub;
120 let stack: Stack<Link | undefined> | undefined;
121
122 top: do {
123 const sub = link.sub;
124 let flags = sub.flags;
125
126 if (!(flags & (ReactiveFlags.RecursedCheck | ReactiveFlags.Recursed | ReactiveFlags.Dirty | ReactiveFlags.Pending))) {
127 sub.flags = flags | ReactiveFlags.Pending;
128 if (innerWrite) {
129 sub.flags |= ReactiveFlags.Recursed;
130 }
131 } else if (!(flags & (ReactiveFlags.RecursedCheck | ReactiveFlags.Recursed))) {
132 flags = ReactiveFlags.None;
133 } else if (!(flags & ReactiveFlags.RecursedCheck)) {
134 sub.flags = (flags & ~ReactiveFlags.Recursed) | ReactiveFlags.Pending;
135 } else if (!(flags & (ReactiveFlags.Dirty | ReactiveFlags.Pending)) && isValidLink(link, sub)) {
136 sub.flags = flags | (ReactiveFlags.Recursed | ReactiveFlags.Pending);
137 flags &= ReactiveFlags.Mutable;
138 } else {
139 flags = ReactiveFlags.None;
140 }
141
142 if (flags & ReactiveFlags.Watching) {
143 notify(sub);
144 }
145
146 if (flags & ReactiveFlags.Mutable) {
147 const subSubs = sub.subs;
148 if (subSubs !== undefined) {
149 const nextSub = (link = subSubs).nextSub;
150 if (nextSub !== undefined) {
151 stack = { value: next, prev: stack };
152 next = nextSub;
153 }
154 continue;
155 }
156 }
157
158 if ((link = next!) !== undefined) {
159 next = link.nextSub;
160 continue;
161 }
162
163 while (stack !== undefined) {
164 link = stack.value!;
165 stack = stack.prev;
166 if (link !== undefined) {
167 next = link.nextSub;
168 continue top;
169 }
170 }
171
172 break;
173 } while (true);
174 }
175

Callers 2

triggerFunction · 0.85
signalOperFunction · 0.85

Calls 2

isValidLinkFunction · 0.85
notifyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…