Skip to content

kimiashz/cancellablePromise

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CancellablePromise

make native javascript Promise Cancellable.

Features :

  • Behavior like native Promise.
  • Add Cancel state: Pending, Resolved, Rejected, +Canceled
  • Can use instead of Promise Builted-in Object.
  • Can call Cancel callback after chained promise.
  • Can't change the promise state after promise is changed to Rejected, Fullfiled or Canceled.
    const myPromise = new CancellablePromise((resolve, reject) => {
        // write your code
    });

    myPromise.cancel = () => {}

    const cahined = myPromise
        .then(handleFulfilled, handleRejected)
        .catch(handleRejected)
        .finally(handleFinally);

    cahined.cancel();

About

add the cancel state to native Promise

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published