Completes with map and flatmap
sharmapankaj2512 opened this issue · 5 comments
Thanks for the wonderful vlingo-actors library :)
At present I am trying to port my pet project to vlingo platform. In one of my usecases, I want to be able to do something like Completes<Int>
to Completes<String>
. Completes as of now doesn't support map/flatmap. From the Completes
interface I understand I could use andThenTo
.
It would be really awesome if Completes
interface makes this a little easier, do you have any plans to add map/flatmap?
Hi @sharmapankaj2512 Maybe. TBF, flatMap()
is only easier to reason about if you are already FP efficient. I think you will find that andThen()
and andThenTo()
to be intuitive. We are lacking some docs, but to make it clear:
andThen()
- Pipe the Completes
outcome to the registered synchronous filter Function
andThenTo()
- Pipe the Completes
outcome to the registered asynchronous filter Function
that passes the outcome as parameter to an Actor
via message send.
Makes sense?
Yes, it does. andThenTo
is what I am looking for, need to change the way I am thinking. Thanks :-)
@sharmapankaj2512 It's ok if you think flatMap()
when using a FP language. We want developers to feel comfortable with monadic expressions in vlingo-*
without knowing the word monad or its meaning. Thanks for accepting our suggested API :)
After playing with Completes
for a while, I feel the existing API is good enough as it guides towards proper usage of the actors. I am closing the issue, thanks you so much for the explanation :)
Cool, thanks! Here is some documentation that just turned up :)
https://docs.vlingo.io/vlingo-common
https://twitter.com/vlingo_io/status/1075619123558678529