Open jtdLab opened 2 years ago
I think the alternative solution you proposed of exposing an Emitter
would be better, as it would give a more consistent experience between Bloc
and Cubit
.
It would be even cooler if the Emitter
is returned by an emit
property, replacing the emit(State)
method.
It would be a breaking change, not sure how big a breaking change though, as the main usage of emit
(just calling emit(newState)
) would still work as intended.
This would be a great feature. Are there any plans of implementing this? Or any ways to contribute to this?
Description
When working with a
Cubit
that consume some otherStream
you need to maintain aStreamSubscription
during the life of theCubit
and close it etc. This comes with some extra work which is handled well inBloc
viaemit.forEach
/emit.onEach
but no similar solution exists for that when usingCubit
.Desired Solution
Adding the methods
emitForEach
andemitOnEach
with same signatures and functionality as their counter part inEmitter
.Alternatives Considered
Maybe give a
Cubit
its ownEmitter
.