promise-watch
This module watches promise objects which have been made, and tells whether all promises have been settled or not.
Note about terminology
A Promise is in one of these states:
・pending: initial state, neither fulfilled nor rejected.
・fulfilled: meaning that the operation completed successfully.
・rejected: meaning that the operation failed.
Note: A promise is said to be settled if it is either fulfilled or rejected, but not pending.
Promise - JavaScript | MDN
Installing
npm install promise-watch
Usage example
https://higuri.github.io/promise-watch/
Code snippet from example page
const PromiseWatch = ; { ... } { ... } // loader: loading iconconst loader = document;// textarea: status linesconst textarea = document;// button: start a taskconst button = document; // create a watch instanceconst watch = ;// subscribe 'added' eventwatch;// subscribe 'allSettled' eventwatch; button;
PromiseWatch
class Constructor
Example:
const watch = ;
run(_: Promise<any>): Promise<any>
Example:
watch;
await watch;// lines to be executed after Foo() ...
watch;// lines to be executed in asynchronously with Foo() ...
onAdded(_: (Promise<any>) => void): void
Example:
watch;
onAllSettled(_: () => void): void
Example:
watch;
onOneSettled(_: (Promise<any>) => void): void
Example:
watch;
pendings: Array<Promise<any>>
Example:
console;