Closed albert-nowak closed 6 years ago
Hi, thank you so much! 🙏
I'm sorry to say though, that I'm actually not interested in adding methods like these to the library. It's roughly a 10% increase in size, and it's just a getter. The library should be limited to reconnecting support & that's it imo.
Instead, we can do this:
let ws;
let socket = new Sockette('...', {
onopen(ev) {
ws = ev.target; // always updates
}
});
// elsewhere
ws.readyState;
Achieves the same & only adds 10 bytes to what's likely already there.
Closing this, but I do really appreciate it 🥇
Cool! TBH didn't know that I can access socket state via ev.target
👍
Yeah! It's kinda sneaky haha, but makes sense once you remember that that's how all EventListeners work 😅 You can access the native ws
on any event handler~
This PR adds an extra method that returns status code of the WebSocket.