I have a simple app which 2 tabs, I am trying to you the bloc pattern to move data around.
Flow 1: 1. App starts bloc is created with a seeded value 2. Build method is run for the page and data shows 3. User switches to another tab 4. User switches back, in this case no data is shown as the steam has already be been read once.
One option would be to resubscribe to send the seed value again.
Flow 2: 1. App starts bloc is created with a seeded value 2. Build method is run for the page and data shows 3. User changes the filters - which fires of the stream data is loaded 3. User switches to another tab 4. User switches back, in this case no data is shown as the steam has already be been read once.
In this case, I want the filter to be kept in place and don't want to use the seed value
Bloc
class DemoBloc {
final DemoApi demoApi;
Stream<String> _results = Stream.empty();
Stream<String> get results => _results;
BehaviorSubject<String> _tabName =
BehaviorSubject<String>.seeded('abc');
// BehaviorSubject<String> _tabName =
// BehaviorSubject<String>();
Sink<String> get tabName => _tabName;
DemoBloc(this.demoApi) {
print('initialized');
_results = _tabName
.asyncMap((tab) => tab)
.asBroadcastStream();
}
void dispose() {
_tabName.close();
}
}