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

Comments

Projects
None yet
2 participants
@sbordet
Member

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

This comment has been minimized.

Show comment
Hide comment
@sbordet

sbordet Dec 17, 2013

Member

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

Member

sbordet commented Dec 17, 2013

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

@sbordet

This comment has been minimized.

Show comment
Hide comment
@sbordet

sbordet Dec 23, 2013

Member

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.

Member

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

This comment has been minimized.

Show comment
Hide comment
@chchrist

chchrist Oct 1, 2015

Is this still under the radar?

chchrist commented Oct 1, 2015

Is this still under the radar?

@sbordet

This comment has been minimized.

Show comment
Hide comment
@sbordet

sbordet Oct 1, 2015

Member

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 :)

Member

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

This comment has been minimized.

Show comment
Hide comment
@chchrist

chchrist 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

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