You can not reuse the promise to go back to the Pending state, but you can create a new one. You can write another generator function to get a new promise on the Fly.
And to deal with returning undefined in async/await; you can do the following:
What Promise.resolve does is that it converts a non-promise value given to it to a Promisified value and hence you can await on it; and if the value passed to Promise.resolve is already a promise, i.e. then-able value; it will continue working as a regular value
Yes, thank you, this is exactly what I need!
One question, though... how would I write a generator function for Promises?
Search returns nothing, besides information on the Promises themselves.
Shouldn't my existing returnCollectionsId() already work as a generator? From how I see it, it should return a new Promise everytime it is called, but it doesn't. So that's the part I don't get.
Just send an article my way that explains the topic further. Can't find one :\ Thank you again!
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
You can not reuse the promise to go back to the Pending state, but you can create a new one. You can write another generator function to get a new promise on the Fly.
And to deal with returning undefined in async/await; you can do the following:
What
Promise.resolve
does is that it converts a non-promise value given to it to a Promisified value and hence you can await on it; and if the value passed toPromise.resolve
is already a promise, i.e. then-able value; it will continue working as a regular valueYes, thank you, this is exactly what I need!
One question, though... how would I write a generator function for Promises?
Search returns nothing, besides information on the Promises themselves.
Shouldn't my existing returnCollectionsId() already work as a generator? From how I see it, it should return a new Promise everytime it is called, but it doesn't. So that's the part I don't get.
Just send an article my way that explains the topic further. Can't find one :\ Thank you again!