How to Know what should I choose from BLOC or Cubit

Viewed 961

Recently I learned about BLOC architectural patterns. From that, I get know that I had 2 choices to use Bloc or Cubit which both of which emit new states but BLOC reacts for Events from UI and Cubit is for Functions received from UI. I know that the BLOc is more advance than Cubit. So how I exactly determine what should I use from bloc or cubit for different states of the app.

1 Answers

See the talk here: https://github.com/felangel/bloc/issues/1444

The main advantage of BLoC is an ability to filter messages which you do not need most of the time. Debouncing of search input changes is the most common example.

BLoC comes with an overhead which in many cases brings no value. When you design your interface, it is safe to start with Cubit. Then you can always convert it to BLoC by changing the internals of your 'setValue()' methods to adding data to streams under the hood. You may do this if you find you are doing too much manual filtering in your setter.

Related