execution_queue 1.2.0 copy "execution_queue: ^1.2.0" to clipboard
execution_queue: ^1.2.0 copied to clipboard

Transaction like execution queue to synchronize asynchronous jobs.

example/main.dart

import 'package:execution_queue/execution_queue.dart';
import 'package:collection/collection.dart';

void main() async {
  // create queue
  final queue = ExecutionQueue();
  var numbers = [];

  // add task to queue
  queue.add<void>(
      () => Future.delayed(Duration(seconds: 4), () => numbers.add(1)));

  queue.add<void>(
      () => Future.delayed(Duration(seconds: 2), () => numbers.add(2)));

  queue.add<void>(
      () => Future.delayed(Duration(seconds: 7), () => numbers.add(3)));

  // add task with Future<String> response
  var hello = await queue
      .add<String>(() => Future.delayed(Duration(seconds: 7), () => 'world'));

  assert(hello == 'world');
  assert(ListEquality().equals(numbers, [1, 2, 3]));
}
2
likes
150
pub points
69%
popularity

Publisher

unverified uploader

Transaction like execution queue to synchronize asynchronous jobs.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

More

Packages that depend on execution_queue