bloc_concurrency 0.2.4 copy "bloc_concurrency: ^0.2.4" to clipboard
bloc_concurrency: ^0.2.4 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 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';

sealed class CounterEvent {}

final class CounterIncrementPressed extends CounterEvent {}

class CounterBloc extends Bloc<CounterEvent, int> {
  CounterBloc() : super(0) {
    on<CounterIncrementPressed>(
      (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 #

414
likes
140
pub points
99%
popularity
screenshot

Publisher

verified publisherbloclibrary.dev

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

Homepage
Repository (GitHub)
View/report issues
Contributing

Topics

#bloc #concurrency #state-management

Documentation

Documentation
API reference

License

MIT (LICENSE)

Dependencies

bloc, stream_transform

More

Packages that depend on bloc_concurrency