A package which has useful implementations of streams for bloc considered with the clean architecture way and is fully tested
- Written for the usage with
Clean Architecture - Provides
Streammixins when can be intergrated with blocs/cubits - Uses
Eitherfrom dartz to get the proper stream data.
Add to the pubspec dependencies
dependencies:
bloc_services: <latest-version>
flutter_bloc: <latest-version>Check the full example in the example directory on how to use it effectively with bloc.
class ExampleBloc
extends Bloc<ExampleEvent, ExampleState>
with
MultipleStreamMixin{
MultipleStreamExampleDartBloc() : super(MultipleStreamExampleInitial());
@override
Stream<MultipleStreamExampleState> mapEventToState(
MultipleStreamExampleEvent event,
) async* {}
@override
Map<Object, StreamData<Object, Object>> get streams => {};
}
Mix your bloc with the MultipleStreamMixin when mixed it has an override called streams
It's a Map<Object, StreamData<Object, Object>> where your can pass a unique key (any object, check the example directory for a detailed implementation) and a StreamData which has a field stream
streamhas the returnTypeof Either<L,R> where theLis considered as anerrorand theRis considered as a valid dataStreamDatahas 2 Type Parameters <L,R> these types will be used as the return type of the fieldstream- when ever a stream emits
Rof the either a function nameonStreamDatawill be called which has 2 params one is thekeywhich was given in thestreams mapin the override and the other is thedataof theR; onStreamErroris called whenever theLof the either is called