notifySubscribers method
void
notifySubscribers()
Notifies all live subscribers that this node has changed.
Dead weak references are pruned before and after the notification pass. The listener list is snapshot-copied before iteration so that mutations to the subscriber set during callbacks are safe.
Implementation
void notifySubscribers() {
if (_isDisposed) return;
final listeners = <ZenithSubscriber>[];
var current = _head;
while (current != null) {
final next = current.next;
final target = current.subscriber.target;
if (target == null) {
// prune dead
if (current.prev != null) {
current.prev!.next = current.next;
} else {
_head = current.next;
}
if (current.next != null) {
current.next!.prev = current.prev;
} else {
_tail = current.prev;
}
current.linked = false;
_subscriberCount--;
} else {
listeners.add(target);
}
current = next;
}
for (final listener in listeners) {
listener.onNodeChanged(this);
}
}