update method
Optimized update method that can notify specific listeners or all listeners
Implementation
void update([List<String>? updateIds]) {
if (_checkDisposed('update')) return;
_updateCount++;
if (ZenConfig.enablePerformanceMetrics) {
ZenMetrics.incrementCounter('controller.update');
}
if (updateIds?.isEmpty ?? true) {
final allListeners =
_updateListeners.values.expand((set) => set).toList();
_notifyListeners(allListeners);
} else {
final listenersToNotify = <VoidCallback>[];
for (final updateId in updateIds!) {
final listeners = _updateListeners[updateId];
if (listeners != null) {
listenersToNotify.addAll(listeners);
}
}
_notifyListeners(listenersToNotify, updateIds);
}
if (_updateCount % 100 == 0) {
_cleanupUpdateListeners();
}
}