API call and map to UI object val moviesList = api.getPopularMovies() .map { //do something } // Emit the list to the stream emit(moviesList) }.flowOn(Dispatchers.IO) }
Int) = flow { // get the comment Data from the api val comment=apiService.getComments(id) // Emit this data wrapped in // the helper class [CommentApiState] emit(CommentApiState.success(comment)) }.flowOn(dispatcher)