fut_map 0.0.4 copy "fut_map: ^0.0.4" to clipboard
fut_map: ^0.0.4 copied to clipboard

Concurrent futures map. Allows setting a concurrency level when mapping an iterable with futures

fut_map #

Description #

Map over futures in parallel.

The problem with Future.wait is that you have to start all futures at the same time. fut_map allows you to control the concurrency over a list of futures.

Usage #

import 'dart:math';
import 'package:fut_map/fut_map.dart';

Future<int> delayedSquare(int x) async {
    await Future.delayed(Duration(milliseconds: Random().nextInt(2000)));
    return x * x;
}

void main()  {
  fMap([1,2,3,4,5,6,7,8,9], delayedSquare, parallel: 3).then((result) {
    // Iterable<int> result;
    print("Result $result");
  });
}
6
likes
130
pub points
0%
popularity

Publisher

verified publisherbekind.software

Concurrent futures map. Allows setting a concurrency level when mapping an iterable with futures

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

More

Packages that depend on fut_map