Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
class SearchViewModel {
//Stream <=> MediatorLiveData
final StreamController<SearchViewState> _viewModelController = StreamController();
final OmdbRepository _repository;
//Stream <=> LiveData
Stream<SearchViewState> get viewState => _viewModelController.stream;
//constructor
SearchViewModel(this._repository) {
_start();
}
void _start(){
this.search("avengers");
}
void search(String name) async {
var movies = await _repository.searchMovies(name);
_viewModelController.add(SearchViewState(movies: movies));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment