batching_future 0.0.3 copy "batching_future: ^0.0.3" to clipboard
batching_future: ^0.0.3 copied to clipboard

outdated

Batches multiple requests into a single batch requests which triggers once the maximum wait time or the maximum batch size is reached.

example/lib/main.dart

import 'dart:async';

import 'package:batching_future/batching_future.dart';

class Doubler implements BatchComputer<int, int> {
  @override
  Future<List<int>> compute(List<int> batchedInputs) {
    return Future.value(batchedInputs.map((i) => i * 2).toList());
  }
}

main(List<String> args) async {
  final batcher = createBatcher(Doubler(),
      maxBatchSize: 3, maxWaitDuration: Duration(milliseconds: 500));
  final inputs = [4,6,8];
  final futures = inputs.map((i) => batcher.submit(i));
  final results = await Future.wait(futures);
  print(results);
}
2
likes
40
pub points
0%
popularity

Publisher

unverified uploader

Batches multiple requests into a single batch requests which triggers once the maximum wait time or the maximum batch size is reached.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

BSD-2-Clause (LICENSE)

Dependencies

quiver, synchronized

More

Packages that depend on batching_future