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
Stream
mixins when can be intergrated with blocs/cubits - Uses
Either
from 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
stream
has the returnType
of Either<L,R> where theL
is considered as anerror
and theR
is considered as a valid dataStreamData
has 2 Type Parameters <L,R> these types will be used as the return type of the fieldstream
- when ever a stream emits
R
of the either a function nameonStreamData
will be called which has 2 params one is thekey
which was given in thestreams map
in the override and the other is thedata
of theR
; onStreamError
is called whenever theL
of the either is called