You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This makes it easy to create Task sequences that can be cancelled.
How does that verbose and hard to learn syntax compare to just awaiting async functions in a loop, then simply breaking the loop in order "to create Task sequences that can be cancelled"?
For example, assume some tool called TaskRunner, written with ES2016 async/await in mind (all promise based):
That (basically) does what you said, but is a ton more readable (of course, features can be added like error handling, pausing tasks, keeping track of running state and percent complete, etc).
Maybe I'm not seeing the benefit of the Tasks yet (thanks for writing about them for me to read about in the first place 😄 ).
The text was updated successfully, but these errors were encountered:
Besides, by merely having promises/async/await in the language, can't we simply implement the other mechanisms (tasks and observables) using async/await, so that the following is possible?
importobservablefrom'somewhere'letgetStockPriceByName=observable(asyncfunction(stockName){letsymbol=awaitgetStockSymbol(stockName);letprice=awaitgetStockPrice(symbol);returnprice;})// Note, called without `await`:letprice=getStockPriceByName("Netflix");letsubscription=price.subscribe(price=>console.log("The price of Netflix is ",price));
You mention in the README that
How does that verbose and hard to learn syntax compare to just
await
ingasync
functions in a loop, then simply breaking the loop in order "to create Task sequences that can be cancelled"?For example, assume some tool called TaskRunner, written with ES2016 async/await in mind (all promise based):
That (basically) does what you said, but is a ton more readable (of course, features can be added like error handling, pausing tasks, keeping track of running state and percent complete, etc).
Maybe I'm not seeing the benefit of the Tasks yet (thanks for writing about them for me to read about in the first place 😄 ).
The text was updated successfully, but these errors were encountered: