2.0.0 • Published 11 months ago

dart-completer v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

Dart Completer

npm npm

A Typescript port of Dart's Completer.

Use it like a Promise that you can complete from the outside.

Note that you can only complete a Completer once, either by calling .complete() or .completeError(). Subsequent calls to .complete() or .completeError() are ignored.

Usage

Without value

const completer = new Completer();

setTimeout(() => {
  completer.complete();
}, 1000);

await completer.promise; // => Completes after 1 second.
await completer; // => Alternative, identical syntax

With value

const completer = new Completer<string>();

setTimeout(() => {
  completer.complete("done.");
}, 1000);

const a = await completer.promise; // => "done."
const b = await completer;         // => "done."
2.0.0

11 months ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago