nodejs / promises

Promises Working Group Repository
107 stars 11 forks source link

Document how promises work #7

Closed benjamingr closed 7 years ago

benjamingr commented 8 years ago

We should document in this repo how promises work with several examples.

This would help communication and allow people who are not domain experts to better get acquainted and get involved in the WG.

spion commented 8 years ago

+1

Another thing that can be discussed is safe resource and state management in the face of errors using finally (and patterns that can be built on top of it)

chrisdickinson commented 8 years ago

I would be happy to work on this.

MadaraUchiha commented 8 years ago

Perhaps, common patterns like

Promise.all(arrayOfData.map(promisingAction)).then(allDataResult => {
  // use
});

Or would that be too broad?

kriskowal commented 8 years ago

This is the approach I took to explaining how promise libraries are designed (partially):

https://github.com/kriskowal/q/blob/v1/design/README.js

On Mon, Feb 15, 2016 at 12:45 PM Madara Uchiha notifications@github.com wrote:

Perhaps, common patterns like

Promise.all(arrayOfData.map(promisingAction)).then(allDataResult => { // use });

Or would that be too broad?

— Reply to this email directly or view it on GitHub https://github.com/nodejs/promises/issues/7#issuecomment-184386788.

petkaantonov commented 8 years ago

@kriskowal this is very good, thanks for posting it

chrisdickinson commented 8 years ago

@kriskowal Thanks! I will definitely draw from this. I am leaning towards making an easily digestible, 300-500 word guide that describes how promises are commonly used by users, including async/await examples alongside raw promise use — the goal is to convey the core use cases of promises. As a separate guide I will try to document how promises are implemented in V8 so we have a common understanding there.