My use of the classic (or "vintage") BLoC pattern (not to be confused with Felix Angelov's great bloc
library) has evolved over the years. I do no use dedicated sinks for input and dedicated streams for output. Rather, I directly use rxdart
's excellent BehaviorSubject
directly. BehaviorSubject
implements ValueStream
, which itself implements Stream
, so I found that I could reduce boilerplate a lot by doing this. Values can be directly added to, and read from, a BehaviorSubject
. I then use provider
to pass my services (I don't really think of them as "bloc"s any more) through my app. This gist provides a real example of how I currently use this pattern.
prefs_service.dart
is where the service is defined.main.dart
shows how to initialize the service.app.dart
shows how I useMultiProvider
to pass down my service. I always useMultiProvider
rather than one single provider to allow for more services. I listen to theBehaviorSubject
in my service to set theThemeMode
of my `Ma