arikw / flat-promise

Create a fresh new Promise with exposed 'resolve' & 'reject' callbacks available outside of its executor function
MIT License
2 stars 0 forks source link

Add properties to Promise to check whether it's resolved or rejected? #1

Closed jacobg closed 4 years ago

jacobg commented 4 years ago

This is a very useful project to get rid of boilerplate!

In the theme of adding method and properties to Promise to strip out this boilerplate, it would be very useful to have properties or methods that indicate whether the Promise has been resolved or rejected, and even the resolve/reject value.

arikw commented 4 years ago

Thank you for your feedback. Although the package can reduce boilerplate code, that's not its main purpose, so I would avoid adding features that don't serve the main goal - having a "flatter" (indentation-wise) code.

If there will be more suggestions like your, I would consider adding an extendable result to support plugins, like:


// done once:
flatPromise.extend(querablePromise);

// usage:
const promise = flatPromise();
console.log( promise.isResolved() );

where querablePromise will be something like described here and will extend the resulted promise