feat: ignore adding a new even if the bloc is closed
cyrax111 opened this issue · comments
Alexander Bosak commented
Description
When we are adding an event to bloc it can be closed if so it will generate an exception. A bunch of adding events are following after async gap and at that moment the bloc can be closed.
What is the best practice to avoid the exceptions? Always check of closing state before adding an event?
Desired Solution
Ignore adding a new even if the bloc is closed.
Felix Angelov commented
Hi @cyrax111 👋
Thanks for opening an issue!
I recommend checking if a bloc has been closed before adding an event if the event is added asynchronously (this is similar to how StreamController
works. Hope that helps 👍