getFeed method

Stream<Feed> getFeed({
  1. required String tag,
  2. required FeedSortOrder sort,
  3. bool requestLatest = false,
})

Implementation

Stream<Feed> getFeed({
  required String tag,
  required FeedSortOrder sort,
  bool requestLatest = false,
}) {
  final key = _getKey(tag, sort.name);
  final BehaviorSubject<Feed> controller;
  if (_feedStreamControllers.containsKey(key)) {
    controller = _feedStreamControllers[key]!;
  } else {
    controller = BehaviorSubject<Feed>();
    _feedStreamControllers[key] = controller;

    unawaited(
      _fetchAndAddFeed(
        tag: tag,
        sort: sort,
        requestLatest: requestLatest,
      ),
    );
  }

  return controller.asBroadcastStream();
}