tek_handle_race_condition

Creator: coderz1093

Last updated:

0 purchases

tek_handle_race_condition Image
tek_handle_race_condition Images

Languages

Categories

Add to Cart

Description:

tek handle race condition

Features #

Flutter handle race condition

Getting started #

Add this to your package's pubspec.yaml file

dependencies:
tek_handle_race_condition: ^0.0.1
copied to clipboard
Usage #
import 'package:tek_handle_race_condition/tek_handle_race_condition.dart';

void main() async {
final TekHandleRaceCondition<String> tekHandleRaceCondition = TekHandleRaceCondition<String>();

final DateTime time = DateTime.now();
print("Start time: $time");

Future<String> callApi(int i) async {
await Future.delayed(Duration(seconds: i));
return 'After ${i}s: $i';
}

final result = await Future.wait([
tekHandleRaceCondition.call(() => callApi(2)),
tekHandleRaceCondition.call(() => callApi(3)),
tekHandleRaceCondition.call(() => callApi(4)),
tekHandleRaceCondition.call(() => callApi(5)),
]);

print("tekHandleRaceCondition.isCompleted ${tekHandleRaceCondition.isCompleted}");

print("End time: ${DateTime.now()}");
print("Time run function: ${DateTime.now().difference(time).inSeconds}s");

print("Result: $result");
}
copied to clipboard
❤️ Buy me a coffee #

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.