Great article, I stubble with the same issues a while back, and started using github.com/fluture-js/Fluture it basically transforms promises into monads, something like:
constFuture=require('fluture')const{compose,map}=require('ramda')constgreet=name=>Future.of(`Hello ${name}`)constexclaim=line=>Future.of(`${line}!`)consttrace=x=>console.log(x)// With function composition (Ramda)constsayHello=compose(map(trace),map(greet),exclaim)sayHello("bob").fork(console.error,console.log)
I convert all my promises to futures, if it fails instead of catching the error, the map will not be triggered and I can use mapRej to deal with the error
Cofounded Host Collective (DiscountASP.net). Cofounded Player Axis (Social Gaming). Computer Scientist and Technology Evangelist with 20+ years of experience with JavaScript!
fluture is one of those project I have read about, always wanted to use and have never used. I need to block out some time and just use it one day. I feel like even if I don't end up using it I will learn a lot.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Great article, I stubble with the same issues a while back, and started using github.com/fluture-js/Fluture it basically transforms promises into monads, something like:
I convert all my promises to futures, if it fails instead of catching the error, the map will not be triggered and I can use
mapRej
to deal with the errorfluture is one of those project I have read about, always wanted to use and have never used. I need to block out some time and just use it one day. I feel like even if I don't end up using it I will learn a lot.