bloc_concurrency 0.1.0
bloc_concurrency: ^0.1.0 copied to clipboard

Custom event transformers inspired by ember concurrency. Built to be used with the bloc state management package.

Bloc Concurrency

Pub build codecov Star on Github style: effective dart Flutter Website Awesome Flutter Flutter Samples License: MIT Discord Bloc Library


A Dart package that exposes custom event transformers inspired by ember concurrency. Built to work with bloc.

Learn more at bloclibrary.dev!


Sponsors #

Our top sponsors are shown below! [Become a Sponsor]


Try the Flutter Chat Tutorial  💬

Event Transformers #

Event Transformers

bloc_concurrency provides an opinionated set of event transformers:

  • concurrent - process events concurrently
  • sequential - process events sequentially
  • droppable - ignore any events added while an event is processing
  • restartable - process only the latest event and cancel previous event handlers

Usage #

import 'package:bloc/bloc.dart';
import 'package:bloc_concurrency/bloc_concurrency.dart';

abstract class CounterEvent {}

class Increment extends CounterEvent {}

class CounterBloc extends Bloc<CounterEvent, int> {
  CounterBloc() : super(0) {
    on<Increment>(
      (event, emit) async {
        await Future.delayed(Duration(seconds: 1));
        emit(state + 1);
      },
      /// Specify a custom event transformer from `package:bloc_concurrency`
      /// in this case events will be processed sequentially.
      transformer: sequential(),
    );
  }
}

Dart Versions #

  • Dart 2: >= 2.12

Maintainers #

62
likes
130
pub points
95%
popularity

Publisher

bloclibrary.dev

Custom event transformers inspired by ember concurrency. Built to be used with the bloc state management package.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

bloc, stream_transform

More

Packages that depend on bloc_concurrency