Closed hawkinsjb1 closed 4 years ago
Hi, could you provide more context?
This goes against the very basics of architecture an app. With BLoC or any other state management solution, you are trying to separate your code to layers - view and logic. Try rather architecture-out your problem, so you would keep your code nice and clean. 💙
Hi @hawkinsjb1 👋 Thanks for opening an issue!
As @tenhobi mentioned this violates the bloc library paradigm. I think in this case, the problem is it seems you're thinking of states as triggers when the events should be the triggers.
Rather than having an AddedObject
state I would recommend having an AddedObject
event which triggers an update in the bloc's state. Hope that helps!
Closing for now but feel free to comment with additional questions and I'm happy to continue the conversation 👍
Sometimes I find myself using states to trigger a certain listener, and once the listener has been triggered I would like to go back to an 'Idle' state. I know I can create empty events that meet this purpose, but I was wondering if we could do this inline from a BlocProvider.of(context) reference. For example:
I realize this may go against the BLoC pattern, but it would also reduce unnecessary boilerplate