bloc_stream 7.0.3 copy "bloc_stream: ^7.0.3" to clipboard
bloc_stream: ^7.0.3 copied to clipboard

A simple package that helps you to implement the BLoC pattern in your applications.

A simple package that helps you to implement the BLoC pattern in your applications.

The BlocStream class is simply a Stream<State>, with a value property.

A BlocStream is also a sink of actions. By calling add with an action function (Action<Bloc, State>), the bloc will then call that action and merge the resulting State's into the output stream.

Here is an example BLoC that provides a list of events:

import 'package:bloc_stream/bloc_stream.dart';
import 'package:example/event_repository.dart';

// Actions
BlocStreamAction<List<Event>> fetch(EventRepository repo) => (currentValue, add) async =>
    repo.list().then(add);

// Bloc
class EventsBloc extends BlocStream<List<Event>> {
  EventBloc() : super([]);
}

Usage with Flutter #

See flutter_bloc_stream.

You can also use this package in combination with Provider and StreamBuilder.

You could also use a StreamProvider from the Provider package.

3
likes
160
points
416
downloads

Publisher

verified publishertimsmart.co

Weekly Downloads

A simple package that helps you to implement the BLoC pattern in your applications.

Repository (GitLab)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

meta

More

Packages that depend on bloc_stream