Skip to content

Instantly share code, notes, and snippets.

@pawelsa
Last active July 6, 2022 19:17
Show Gist options
  • Save pawelsa/2333b5a6ff0b399cd5cc8a07413e80ef to your computer and use it in GitHub Desktop.
Save pawelsa/2333b5a6ff0b399cd5cc8a07413e80ef to your computer and use it in GitHub Desktop.
final LoadingStatus _upcomingMoviesLoadingStatus = LoadingStatus();
Future<Result> getUpcomingMovies(int page) {
_upcomingMoviesLoadingStatus.isLoading = true;
return _movieApi.getUpcoming(page).then((content) {
if (content is ContentListResponse) {
final result = _getMoviesWithResp(content, false);
_upcomingMoviesLoadingStatus.isLoading = false;
return result;
}
_upcomingMoviesLoadingStatus.isLoading = false;
return ErrorResult(ErrorCause.noInternet());
});
}
DataStream<List<ContentDetailData>> observeDetailedUpcoming() =>
_movieDao.observeAllUpcoming()
.asyncMap(getDetailsFromDb)
.withLoading(_upcomingMoviesLoadingStatus);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment