Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

pragmatrix/iwhen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

iwhen, Immediate Promises

This is an unfinished port of when.js to typescript that is specifically built to avoid delaying callbacks.

In this implementation, every callback passed to the library gets either called immediately or directly from within the context of the asynchronous function that fulfills the promise.

This change may have consequences in several areas, like making bugs harder to reproduce, or consuming a lot of stack space when the fulfillment runs synchronously.

But when used carefully, this library may be used for asynchronous APIs that are incompatible with current promise implementations.

APIs that may be used with iwhen

In IndexedDB, a transaction lives as long as new requests are initiated in response to success callbacks from previous requests. If a promise library would delay the callback, the transaction may commit too early and before all the requests went through.

Incompatibilities to when.js

  • deprecated parameters were removed.
  • iwhen.all() is a variadic function and so does not expect arrays. To wait for multiple promises, use iwhen.all(a, b) instead of iwhen.all([a,b]).

License

Licensed under the MIT License.

About

iwhen, Immediate Promises for TypeScript based on when.js

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published