configureDownloadUpdatesStream static method

void configureDownloadUpdatesStream(
  1. Stream<TaskUpdate>? stream
)

Registers a shared download-updates stream for all SmartDownloader paths (new downloads and attach-to-existing).

stream may be single- or broadcast; non-broadcast sources are wrapped with Stream.asBroadcastStream so concurrent downloads can each call Stream.listen.

Implementation

static void configureDownloadUpdatesStream(Stream<TaskUpdate>? stream) {
  _configuredDownloadUpdatesStream = stream;
  _configuredBroadcastStream = null;
  // A hub and our group callback cannot coexist. Group callbacks outrank the
  // `updates` stream in background_downloader's dispatch, so an orphaned
  // registration left over from an earlier download would keep intercepting
  // our tasks and the host's hub — fed by `updates` — would receive nothing
  // at all, hanging every download that resolved to it.
  // NOT absorbing here. A hub is the host saying "route flutter_gemma's
  // updates to me", and group callbacks outrank the `updates` stream that
  // feeds it — so leaving any callback registered, even a silent one, starves
  // the hub and hangs every download that resolves to it. Which is precisely
  // the hazard this call exists to prevent.
  if (stream != null) _releaseGroupFanOut(absorb: false);
}