async
/await
は、以下を達成するためにどのように使用できますか?forEachでasync/awaitをどのように使用できますか?
Promise.all
を使用して
Array#map
で
Array#forEach
への通話を交換する必要が
self.onmessage = event => {
// async stuff in forEach needs to finish
event.data.search.split(',').forEach((s, i) => {
db.get('customers').then(doc => {
...
})
})
// before getting here
}
おそらく[SO上のドキュメント](http://stackoverflow.com/documentation/javascript/925/async -functions-async-await/7746/looping-with-async-await#t = 201703052353271956842)は役に立ちます... – rasmeister
async/awaitはこのコードを不必要に複雑にします - 必ずしも最新のものではなく、光沢のあるガジェット:p –
実際には 'await/async'はまったく役に立たない –