execution_queue 1.1.0+1 copy "execution_queue: ^1.1.0+1" to clipboard
execution_queue: ^1.1.0+1 copied to clipboard

outdated

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
30
pub points
64%
popularity

Publisher

unverified uploader

Transaction like execution queue to synchronize asynchronous jobs.

Repository (GitHub)
View/report issues

License

MIT (license)

More

Packages that depend on execution_queue