Closed kmruiz closed 5 years ago
So you have two options to handle failures:
otherwise
that takes the cause of the failure, and returns a success value.otherwiseInto
that receives the cause of the failure, and the return type is another Outcome, that can be a Success or a Failure itself.Excellent! I think it would be great to add all of the above discussed method/functions that you recommended. I like the filter(...)
but zipWith(...)
doesn't speak to me (maybe not others, either). Can you think of a more fluent descriptive name for this? I also like asOptional()
and asCompletes()
and others. So please just do what you recommend, but maybe with one better name.
This is the signature for
Outcome<Failure, Success>
so we can verify that the implementation will be as expected.If is there any improvement or you find that the interface lacks of a method that you would like to have, feel free to ask for it 😄 .
And I would like also to know if we want to have some functional methods that are quite common on those kind of 'monadic' behaviours. I'm thinking on:
filter(Success -> Boolean)
zipWith(Result<Failure, Success> result)
And maybe some interop with Java and vlingo:
asOptional()
Will return a OptionalasCompletes()
Will return a CompletesNew Methods
getOrNull
Returns the successs or null, as null is the default failure value for vlingo, to support this usage.otherwiseInto
Transforms a Failure to a new outcome (that can be Success or Failure again)