vlingo / xoom-common

The VLINGO XOOM platform SDK common tools shared across various projects.
Other
16 stars 10 forks source link

Completes with map and flatmap #9

Closed sharmapankaj2512 closed 5 years ago

sharmapankaj2512 commented 5 years ago

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?

VaughnVernon commented 5 years ago

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?

sharmapankaj2512 commented 5 years ago

Yes, it does. andThenTo is what I am looking for, need to change the way I am thinking. Thanks :-)

VaughnVernon commented 5 years ago

@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 :)

sharmapankaj2512 commented 5 years ago

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 :)

VaughnVernon commented 5 years ago

Cool, thanks! Here is some documentation that just turned up :)

https://docs.vlingo.io/vlingo-common https://twitter.com/vlingo_io/status/1075619123558678529