stream property

Stream<T?> get stream

Implementation

Stream<T?> get stream async* {
  if (currentValue == null && isReady.isNotStarted) {
    final initialLoad = await loadInitial();
    yield initialLoad;
  } else if (currentValue == null && isReady.isStarted) {
    try {
      final isReadyResult = await isReady.future;
      yield isReadyResult;
    } catch (e, stack) {
      log.severe("Error fetching data for service: $e", e, stack);
      isReady.completeError(e, stack);
      yield null;
    }
  } else {
    yield currentValue!;
  }

  await for (final data in _updateStream.stream) {
    yield data;
  }
}