-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Hello,
what is best practice for combing multiple Bloc state in a new Bloc? For example I have BlocA and BlocB and I want to create a new Bloc which combines both states:
class BlocCombineBloc extends Bloc<BlocCombineEvent, BlocCombineState> {
final BlocABloc blocA;
final BlocBBloc blocB;
BlocCombineBloc(this.blocA, this.blocB);
@override
BlocCombineState get initialState => InitialBlocCombineState();
@override
Stream<BlocCombineState> mapEventToState(
BlocCombineEvent event,
) async* {
Observable.combineLatest2(blocA.state, blocB.state,
(BlocAState stateA, BlocBState stateB) {
if (stateA is BlocALoaded && stateB is BlocBLoaded) {
/// combine data
}
}).listen((data) {
/// do something with data
});
}
}
The problem which I am facing is when my BlocCombineBloc calls disposed(), BlocA and BlocB call also disposed().
felangel
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working