Describe the bug
Hello and thanks for the time in answering this question!
I've created BLoC_A. Let's say that we have two other BLoCs that extend it (as they have mutual shared logic, and I decided
for the sake of brevity not to use composition).
When calling super.mapEventToState it seems like nothing happens, but when calling it with yield*, all of a sudden it works.
I'm wondering why this happens and if anyone has any insight into this issue
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Super is called as usual.
Hi @dorsamet 馃憢
Thanks for opening an issue!
You should not call super.mapEventToState because it returns a stream and must constantly be processing the incoming events. Yield* processes all data on the stream until the stream is closed which is why it works in that case.
Hope that helps 馃憤
The super method is an abstract method. And it should be implemented by the subclass in order to map incoming events to states. Since the return type is Stream you have to use yield to generate(emit) a new state. Please check the official doc about streams.
The super method is an abstract method. And it should be implemented by the subclass in order to map incoming events to states. Since the return type is
Streamyou have to useyieldto generate(emit) a new state. Please check the official doc about streams.
Actually the super method here does have some logic and is not abstract, but I do understand the added complexity with using streams. Maybe it might be a good idea to not do that.
With that said, the super method may actually generate a new state so yield* makes sense to actually be the route to go. I was more wondering why the code was not executed to begin with