Add functional helpers like map, mapErr, biMap (match), flatMap (andThen) etc that can work with both Result... and Promise<Result...
Add .pipe function on Ok and Err, and Promise, pretty much as implemented in rxjs: accept to pass N amount of continuation functions with signature: (previous) => next
The only thing I don’t like is that this brings us back to callbacks, which so elegantly got rid of with await.
Would be great if typescript allows pattern matching, then you’ll do
Rust flavor here
Yes, that's nice. There are a couple of functional languages that support it. E.g. Erlang where I first saw this in action.
Maybe one day!
Actually you can do something similar:
blog.logrocket.com/pattern-matchin...
It’s not as pretty as real pattern matching but it fits to this use car.
github.com/gvergnaud/ts-pattern
One way I was able to deal with 'callback hell':
map
,mapErr
,biMap
(match
),flatMap
(andThen
) etc that can work with bothResult...
andPromise<Result...
.pipe
function onOk
andErr
, andPromise
, pretty much as implemented in rxjs: accept to pass N amount of continuation functions with signature:(previous) => next
so now I can:
(with full Typescript typing support btw!)
Thinking about releasing it to GitHub and npm at some point :)
My post, framework and sample just landed dev.to/patroza/result-composition-...