remoteStream<C extends StateController<S> , S> method
This function returns the state of a the StateController
instance as a Steam depends on the generic types
you attached with the function.
Example
This example returns todo list filtered by searchCategory.
We need SearchCategoryCubit
stream combining with TodoCubit's
stream:
Stream<List<Todo>> get todo$ =>
Rx.combineLates2<List<Todo>, SearchCategory, List<Todo>>(
stream$,
remoteStream<SearchCategoryCubit, SearchCategory>(),
(todos, category) {
switch (category) {
case SearchCategory.Active:
return todos.where((todo) => !todo.completed).toList();
case SearchCategory.Completed:
return todos.where((todo) => todo.completed).toList();
default:
return todos;
}
});
Implementation
Stream<S> remoteStream<C extends StateController<S>, S>() =>
remoteController<C>().flatMap((value) => value.stream$);