watchSyncStatus method
The live SyncStatus stream (spec §3.3). Emits the CURRENT status
immediately on subscribe (so a re-subscribe after a background gap
re-renders at once), then every change coalesced latest-wins. It NEVER
completes on a transient fault — a stall is a SyncStatus.stalled
EVENT, not an error or EOF.
Implementation
@override
Stream<SyncStatus> watchSyncStatus() {
subscribeCount++;
final controller = StreamController<SyncStatus>();
controller.onListen = () {
if (failOnSubscribe) {
controller.addError('fake subscribe failure');
} else {
controller.add(_current);
if (dropAfterReplay) controller.addError('fake post-replay drop');
}
};
controller.onCancel = () {
cancelCount++;
if (identical(_active, controller)) _active = null;
};
_active = controller;
return controller.stream;
}