Closed injecteer closed 3 years ago
can that be done with an extension method in groovy ?
On Thu, Feb 18, 2021 at 1:33 PM injecteer notifications@github.com wrote:
Now to check the AsyncResult instances for success the following code is used:
if( asyncRes.succeeded() ){ println asyncRes.result() }else{ log.error 'Error!', asyncRes.cause() }
I would be good to add a default method to AsyncResult interface to mirror succeeded():
default boolean asBoolean() { return succeeded(); }
to make Groovy code look simpler to read:
if( asyncRes ){ println asyncRes.result() }else{ log.error 'Error!', asyncRes.cause() }
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/vert-x3/issues/issues/576, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABXDCSGM5IDQ5W7V232NBDS7UCJ5ANCNFSM4X2G4HXA .
You mean with global AST transformation? Yes, sure
The amount of code is going to be relatively big comparing to default interface method though
I think the best would be to cnotribute this as an extension method in vertx-lang-groovy in Vert.x 4
we already have extension methods there for Groovy:
On Thu, Feb 18, 2021 at 2:46 PM injecteer notifications@github.com wrote:
You mean with global AST transformation? Yes, sure
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vert-x3/issues/issues/576#issuecomment-781354060, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABXDCQHOJUN42OABLRBETLS7UK2DANCNFSM4X2G4HXA .
I tried shortly the method in Gist and it works like a charm
Do you mind doing a PR ?
On Fri, Feb 19, 2021 at 12:41 AM injecteer notifications@github.com wrote:
I tried shortly the method in Gist and it works like a charm
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/vert-x3/issues/issues/576#issuecomment-781707755, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABXDCTM6IUP6RGBCW27MR3S7WQSNANCNFSM4X2G4HXA .
Have a look please.
Now to check the AsyncResult instances for success the following code is used:
I would be good to add a default method to AsyncResult interface to mirror succeeded():
according to Groovy Truth to make Groovy code look simpler to read: