pladaria / reconnecting-websocket

Reconnecting WebSocket. For Web, React Native, cli (Node.js)
MIT License
1.22k stars 197 forks source link

Promise URL #46

Closed bvandenbos closed 6 years ago

bvandenbos commented 6 years ago

Taking a crack at allowing the URL function to return a Promise a la https://github.com/pladaria/reconnecting-websocket/issues/28.

I ended up having to restructure how eventListeners were managed but managed to get tests passing despite initialization of the underlying WebSocket now being inherently async.

Haven't used this in the wild just yet, but figured I'd submit what I have anyway.

coveralls commented 6 years ago

Coverage Status

Coverage decreased (-4.7%) to 93.814% when pulling c6762debf6eed543ab584db9f55ed315999c6421 on bvandenbos:promise-url into 31a0f01af4c96dfb1ba0c17b1124de204cd0e513 on pladaria:master.

pladaria commented 6 years ago

Thanks, sorry for the delay, I've been really busy lately. I will try to get some time to have a deeper look at your PR.

bvandenbos commented 6 years ago

No worries. I actually ended up not using this lib for my problem. Once the customization reaches a certain point it becomes easier to handle the websocket reconnection manually than try to shoehorn this (or some other reconnecting lib) into place.

Wrappers like this work well for simple cases. To that end, perhaps it's best to not add functionality like this PR and keep the lib simple.

Cheers!

bvandenbos commented 6 years ago

I had already done the work so I figured I'd post it and maybe save someone else time in the future.

pladaria commented 6 years ago

Hi, thanks for contributing.

I've just released a complete rewrite of the library. It now supports (along other features) providing url as: