Conversation

Do not return Future in #dart, it's not safe ⚠️ Wait what! What should I do instead? There is an alternative, and it's easier and safer πŸ’πŸΌβ€β™‚οΈ It's called Task, let's learn about it πŸ‘‡πŸ§΅
9
125
Why not Future? πŸ‘Ž Impure: the result will change at every request πŸ‘Ž Not composable: not easy to work with a sequence of Future πŸ‘Ž Error handling: not easy to handle and spot errors
2
4
How can Task make the function pure? 🀨 Simple: Task doesn't make the request, yet Task is a thunk: a function that, when called, will return a Future πŸ’‘
Image
2
9
Note πŸ’‘ Future is not wrong and it works great 🀝 Task is just a wrapper around Future after all πŸ’πŸΌβ€β™‚οΈ The point is that Task brings extra features and a safer API (Functional programming πŸš€)
Quote Tweet
Replying to @SandroMaglione
I find your tag-line a bit misleading. I think most of us have been using futures just fine. I get that you want to promote your package and it does sound like an improvement, but saying Futures should not be returned might confuse new users.
3
8