3 ms·
Mistakes to Avoid If You Work with Scala Futures
- BalinKing 6y agoI liked the writeup! In my experience, JavaScript Promise (mis)use can share some of these mistakes too—they're probably inherent to the synchronous->asynchronous learning process.
- goblin89 6y agoWhat would be the equivalent to “sending tasks” to a Future instead of awaiting result (re mistake 1) but in JS with Promises? Is it about operating on unresolved promises and awaiting final values as late as possible? Or does that part not apply to JS?
- danidiaz 6y agoThe error is explicitly awaiting for the result; "sending tasks" to the future is the correct way, and corresponds to "then" in Promise.
- jkells 6y agoFor other JS developers the stuff about await isn't relevant. It's not the same as a JS async/await In JS an await is just syntactic sugar around a then() on a promise. The Await in the article is a method to block the thread until a promise resolves, there is no equivalent in JS. .NET has a similar mechanism with Task.Result with similar pitfalls
- vigneshwaran 6y agoYes. The async/await in JS is totally different from Await in plain Scala (without any frameworks)
- vigneshwaran 6y agoThank you for your comment. Yes I felt that the problems could be present in other languages as well but I don't know any other.