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

discontinued
outdated

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 just a Stream with a couple extra methods added to reduce boilerplate. You can subclass it and add your own methods, to implement your business logic.

Internally it uses a BehaviourSubject from the rxdart package to provide data to the stream. The add and addError methods are exposed so you can push state to the stream from your methods.

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

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

// Bloc
class EventsBloc extends BlocStream<List<Event>> {
  EventBloc(this.repository);

  final EventRepository repository;

  @override
  int get initialValue => null;

  Future<void> fetch() async {
    try {
      final events = await repository.list();
      subject.add(events);
    } catch (err) {
      subject.addError(err);
    }
  }
}

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
0
pub points
3%
popularity

Publisher

verified publishertimsmart.co

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

Repository (GitLab)
View/report issues

License

unknown (LICENSE)

Dependencies

meta, rxdart

More

Packages that depend on bloc_stream