lukeed / sockette

The cutest little WebSocket wrapper! 🧦
MIT License
2.45k stars 81 forks source link

adding `binaryType` to opts #51

Open avimak opened 5 years ago

avimak commented 5 years ago

see https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/binaryType

lukeed commented 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.

avimak commented 5 years ago

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".