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

Look at JavaScript promises #490

Open
sbordet opened this issue Dec 17, 2013 · 5 comments
Open

Look at JavaScript promises #490

sbordet opened this issue Dec 17, 2013 · 5 comments

Comments

@sbordet
Copy link
Member

@sbordet sbordet commented Dec 17, 2013

JavaScript promises may make the CometD API a bit cleaner, see http://www.html5rocks.com/en/tutorials/es6/promises/.

@sbordet
Copy link
Member Author

@sbordet sbordet commented Dec 17, 2013

Originally reported by sbordet on 2013-12-17T10:47:31Z

@sbordet
Copy link
Member Author

@sbordet sbordet commented Dec 23, 2013

sbordet on 2013-12-23T16:05:21Z:
CometD's subscribe() method returns a value, which is a problem because async functions must not return a value.

Perhaps there is value in changing subscribe()'s callback to take the subscription object as parameter, in addition to the message, however this will break the existing applications because they expect the return value.

We could add register()/unregister() to differentiate, or make the return value of subscribe() both a subscription object and a promise.

Still thinkering.

@chchrist
Copy link

@chchrist chchrist commented Oct 1, 2015

Is this still under the radar?

@sbordet
Copy link
Member Author

@sbordet sbordet commented Oct 1, 2015

There is no progress on this yet... I'm not sure it's going to be done at all, I am still unconvinced that it will bring benefits worth the effort. Feel free to change my mind :)

@chchrist
Copy link

@chchrist chchrist commented Mar 1, 2016

I think the only benefit would be for request/replies. Everytime you subscribe you create a new Promise and when you get something back the promise gets resolved. I wouldn't use Promises though for notification channels where you remain subscribed cause Promises wouldn't work. I think the best candidate is the remoteCall

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.