sync_once 1.0.2 copy "sync_once: ^1.0.2" to clipboard
sync_once: ^1.0.2 copied to clipboard

The function will be called only once.

sync_once #

The function will be called only once.

The package inspired by sync.Once in Go Language.

Usage #

A simple usage example:

import 'package:sync_once/sync_once.dart';

void main() async {
  final once = SyncOnce();

  Future<void> onceBody() async {
    await once(() async {
      print("Only once");
    });
  }

  // call 3 times
  await Future.wait([
    onceBody(),
    onceBody(),
    onceBody(),
  ]);
}

// => Only once
0
likes
140
pub points
0%
popularity

Publisher

unverified uploader

The function will be called only once.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

synchronized

More

Packages that depend on sync_once