-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide a Scala Future/Promises based API #16
Comments
Narigo, it could be nice to have, I quite like the syntatic sugar you get with for-comprehensions together with Future/Promises. It'd imagine it'd an alternative/experimental API to start with? As you rightly say, we wanna stay close to Vert.x API... Btw, do you have any link to your projects by any chance? |
Q javascript framework is a good example of what narigo proposes: sphagetti: step1(function (value1) { With a promise library, you can flatten the pyramid. Q.fcall(step1) |
Mostly everything we open sourced is here: https://github.com/campudus Check out the module registry, too. We've written it in Scala, added tests and have used Futures there a lot: https://github.com/vert-x/vertx-module-registry |
I had a quick discussion today in the #vertx IRC channel with @purplefox and he said there's an Future/Promises-like API already available for Java in https://github.com/vert-x/mod-rxvertx. It uses RxJava to enable composition. I haven't looked at it yet, but one option would be wrap that around Scala Future/Promises and this nice, composable API. I'm not sure there's a need for another API on top of Scala future/promises necessarily. On on side, future/promises already have flatmap() methods, which is what allows them to be composable in for-comprehension structures. But, even such API can be cumbersome, which is why the Scala Async project was created (https://github.com/scala/async). I think we all agree on the merits of a future/promises based API, so should defo investigate that. And if we can align it with the equivalent one in Java, I think it'd be even better, although with Java8, I wonder what will happen to the rxvertx module... Thx for the links @Narigo :) |
I think it make sense at least try to fuse Scala futures with o.v.j.core.Future into mod-lang-scala for various reasons:
|
I would like to see an api that uses Scala Futures/Promises as I agree However, I would like to take a layered approach
Keep them nice and separate - don't put futures/promises in 1. On 04/07/13 20:29, Edgar Chan wrote:
|
This will add a great value to the project, and definitely should be in a separate package so a developers, only need to read the imports to know that futures are used somewhere in the code. Nicolás Meléndez Twitter: @nfmelendez Sent with Sparrow (http://www.sparrowmailapp.com/?sig) On Thursday, July 4, 2013 at 4:51 PM, Tim Fox wrote:
|
In an IRC meeting earlier today, It was agreed that this API should be separated into a different Vert.x module. |
Hi, this issue is one year old and leaves the thread with a |
I've been working on a prototype for Vert.x 3.x but it's not ready yet, particularly because some callbacks are called several times, where Promise/Futures can't help. |
@sscarduzio FYI, I've posted a basic prototype and some feedback in https://groups.google.com/forum/?fromgroups=#!topic/vertx/9Zbmw2wa5mU |
I have started to write future/promise wrappers for the Scala vert.x API for the most common use-cases along with writing my actual project code. The amount of needed project code decreased while its readability increased dramatically. I highly engourage to head for such an API. By the way: My approach was to define an equivalent trait (self: VertxAccess => ...) for every vert.x API class with equivalent future implementations wherever applicable and practible. I like to be able to fall back to vert.x callback-driven API where this feels to be the better way to go (e.g. handler registration). |
@christian-bick We're already working on the future/promise API, see the lengthy post I sent to the Vert.x users group a while back. However, Future/promises solve only one part of the API: single shot events. Multi-shot events (e.g. handling http requests) are not well suited here, which are more like streams of events (or rx) are a bit more tricky. The important thing to understand is that in the next major Vert.x version, we'll be moving towards generation of Scala APIs, based on our recommendations on how to map each concept to Scala. You might want to look at my prototype on the things we want to improve for next major Vert.x Scala API version. |
About multi-shot events: as Galder said, there's a number of solutions to RX Observable is one of them, in Play they have Iteratees, but the cleanest You can see this widely explained in the last chapter of the book This in my opinion would be the most Scala idiomatic and functional On Thu, Aug 7, 2014 at 6:41 PM, Galder Zamarreño [email protected]
|
I ordered that book when it was on MEAP and hopefully tomorrow the final version of the ebook should be out. I'll be reading it in the next few weeks :). However, the main issue of |
Did this ever end up being added? ATM looking at the scala docs, there doesn't seem to be any support. |
In our projects, we use Futures and Promises to get rid of the nested callbacks. It would be very nice to have them in the API directly instead of having to write them myself.
If you want to stay tied to the Vert.x API, this could also be done as an extra, includable module. Not sure whether this makes much sense, though.
The text was updated successfully, but these errors were encountered: