Skip to content
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

Multiple Async callbacks #34

Open
the-duke opened this issue Jul 8, 2016 · 2 comments
Open

Multiple Async callbacks #34

the-duke opened this issue Jul 8, 2016 · 2 comments

Comments

@the-duke
Copy link

the-duke commented Jul 8, 2016

Hello, I like your rpc framework on top top primus.io. Awesome work! For now, I used in my project dnode rpc with shoe on top of sock.js. I would like to migrate to eureca.io but I need that a server can responed multiple chunks to the client before the async "context.return()" method is called. This would be a kind of streaming, like in dnode or grpc. I know, for this purpose, it is possible do define a stub on the client side, which the server can callback for progress information, but I don't like the coding overhead to associate these client and server functions to each other. A "context.progress()" function would be really nice! On the client side a proxy stub call would callback a progress function passed as third argument to the promise:
proxy.asyncServerHello().then( function(success) {}, function(error){}, function(progress){});

Best regards

Thomas

@alaa-eddine
Copy link
Contributor

Hello @the-duke and welcome to eureca.io :)
Actually I was thinking of an implementation of such solution, but I don't like to add a third callback to the promise, since it's not a standard.
there are many possible solutions, but this need reflexion to make the best solution which cover most of use cases.

one of those could be something like

proxy.asyncServerHello().then( function(success, finished) {}, function(error){}

when the "finished" argument is true, it means that the server called context.return()
otherwise it'll mean that the server called .progress()

this is still not compliant with Promises syntax but it's a better solution imo.

another approach could be something like :

proxy.asyncServerHello().progress(function(value) {}).then( function(success) {}, function(error){}

still trying to figure out the best approach

@the-duke
Copy link
Author

the-duke commented Jul 8, 2016

Thank you for your fast reply an thinking about implementation. I use a lot of dojo toolkit and there the progress callback is passed as third argument. dojo/promise/Promise

But, while dojo might be not very common, i like your first solution with the finished argument.

Thank you a lot, i hope implementation is not too hard work for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants