Open avimak opened 5 years ago
Hey there~!
Do you not like setting the property inside onopen
? I mentioned that here: https://github.com/lukeed/sockette/issues/18#issuecomment-373963513
Not quite sure how I feel about this to be honest. I know it sounds silly, but ideologically, Sockette is just meant to enable easy reconnects. It should provision those listeners & be a doorway into the ws
connection.
I don't mind setting it inside onopen
, but since there were already existing methods which aren't related - directly - to reconnecting, i.e. -
$.json = function (x) {
ws.send(JSON.stringify(x));
};
or -
$.send = function (x) {
ws.send(x);
};
or even -
ws.onmessage = opts.onmessage || noop;
I thought that adding binaryType
to opts wouldn't break the current "paradigm".
see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType