subreddits method

Stream<SubredditRef> subreddits()

A Stream of subreddits which use the new modmail that the authenticated user moderates.

Implementation

Stream<SubredditRef> subreddits() async* {
  final response = await _subreddit.reddit
      .get(apiPath['modmail_subreddits'], objectify: false);
  final subreddits =
      (response['subreddits'] as Map).values.cast<Map<String, dynamic>>();
  final objectified = subreddits.map<Subreddit>((s) =>
      Subreddit.parse(_subreddit.reddit, {'data': snakeCaseMapKeys(s)}));
  for (final s in objectified) {
    yield s;
  }
}