You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I think this would have simplified something I was doing myself in extending classes. I only just stumbled on this @@species today.
I implemented something like this for extending a protocol wrapper around client-side websockets.
exportclassProtocol{constructor(){this.#Protocol =Object.getPrototypeOf(this).constructor;this.#Protocol.ws=null;// allocate a static websocket in the final implementation.}connect(protocol){constThisProtocol=this_.#Protocol;//Object.getPrototypeOf( this ).constructor;ThisProtocol.ws=newWebsocket( ...,protocol);}}
I used to have to get the type with the long expression Object.getPrototypeOf( this ).constructor but realized I could just keep that per instance of a new Protocol(), I think using @@species would have simplified that expression also.
The client protocol is expected to only use a single connection to the server; where the server would have lots of these all over.
I think this would have simplified something I was doing myself in extending classes. I only just stumbled on this @@species today.
I implemented something like this for extending a protocol wrapper around client-side websockets.
I used to have to get the type with the long expression
Object.getPrototypeOf( this ).constructor
but realized I could just keep that per instance of anew Protocol()
, I think using@@species
would have simplified that expression also.The client protocol is expected to only use a single connection to the server; where the server would have lots of these all over.
Example from here: https://github.com/d3x0r/sack.vfs/blob/master/apps/http-ws/client-protocol.js
Well, if nothing else, this is an example of how to get around not having
@@species
?The text was updated successfully, but these errors were encountered: