Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter Firebase BLoC pattern

I want to know how to manage BLoC pattern for Firebase. I couldn't find any example of BLoC for Firebase so it might be broad but forgive me. I saw some basic BLoC implementation but those were basically fetch data or updating view in a active way not passive way also not through database(almost API JSON stuff). So, I want to see how to handle some BLoC pattern for Firestore like get followed(passive way), when user update own profile info something like that. Does anyone lead me to the correct way? Any help is highly appreciated!

like image 546
Daibaku Avatar asked Sep 01 '18 16:09

Daibaku


1 Answers

What BLoC pattern gives you is nothing more than a data stream that can be updated adding new data through the stream.sink.

Using Firestore you already have a data stream, so you might not need BLoC.

If your application requires a more complex logic you might update you BLoC data adding a listener to a firestore ref in the root widget to have db and bloc always in sync (maybe with multiple blocs for multiple db refs).

like image 174
Dario Ielardi Avatar answered Oct 02 '22 01:10

Dario Ielardi