slact / nchan.js

NPM package for the Javasript client for Nchan
Other
91 stars 25 forks source link

Long polling - add delay between polling #14

Closed Xon closed 6 years ago

Xon commented 6 years ago

Add's a configurable delay between polling, and support for changing the polling period without a full stop/start cycle.

I'm not sure if this is the best way to implement reschedulePendingPollRequest, but the entire polling period bit is entirely specific to the long poll transport type.

Xon commented 6 years ago

@slact any feedback on this?

slact commented 6 years ago

I was thinking if the options should be namespaced to opt.longpoll.delay -- this way there will be a clean way to address #9 . but then specifying the options gets a little clunkier - {subscriber: "longpoll", longpoll: {delay: 100}}. Overall, I think I would prefer the namespaced approach. What do you think?

Xon commented 6 years ago

Namespacing the options makes a bunch of sense, it is a bit more clunky but not by much.

Xon commented 6 years ago

@slact I've pushed some minor cleanup on this. Ensured that any cancelling goes via longpoller's cancel() method to ensure everything is cleaned up.