4 ms·
I'm not sure if you have spent much time in a functional language but I found this helped me understand what is going on with a Promise and an Observable. They'
by xupybd 3y ago
I'm not sure if you have spent much time in a functional language but I found this helped me understand what is going on with a Promise and an Observable. They're all Monads. Just like List and Map or the optional Monad.
When I first started learning that sort of thing it made no sense at all. But now it's just a design pattern that allows you to organize things. Having that understanding helps abstract away some of the mechanisms in the observable.
It helped me at least. YMMV
- nine_k 3y agoIndeed! The concept of Monad is simple and very useful; once you learn it, you start seeing it everywhere. JS Promises are not completely monadic though, because a Promise that resolves into a Promise is always effectively auto-flattened into a single Promise. But most of the time other monadic properties of Promises can be used despite this.
- xupybd 3y agoGood to know. I didn't realize that promises were not monads.