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
The standard DOM WebSocket class allows the client to attach listeners to the WebSocket for events such as close, error, open, message. WebSocketClient attaches handlers for these events, but does not expose the events to the consumer; as such, if the websocket gets disconnected, we have no way of knowing or dealing properly with it. Then, if we try to send on the perspective.websocket a runtime error is triggered and it is not an ideal situation to deal with or code against. I would like to propose that the WebSocketClient allow the client to add its own event handlers, at least for 3/4 events... something like (probably botched TS syntax below, but you get the idea):
export class WebSocketClient {
addEventListener(string<"close" | "open" | "error">, CloseEvent | Event);
// other existing methods
}
Potential Solutions:
The only drawbacks I see are if the WS is to be recycled, before it is nil'd out, all handlers should be removed.
Adding this would allow us to better manage how we interact with the state -- given we'll be notified of what the current state of the websocket is at any given moment.
The text was updated successfully, but these errors were encountered:
Feature Request
Description of Problem:
The class
WebSocketClient
which is exposed through theperspective.websocket(url)
function has the following interface:https://github.com/finos/perspective/blob/master/packages/perspective/index.d.ts#L199-L204
The standard DOM WebSocket class allows the client to attach listeners to the WebSocket for events such as
close
,error
,open
,message
.WebSocketClient
attaches handlers for these events, but does not expose the events to the consumer; as such, if the websocket gets disconnected, we have no way of knowing or dealing properly with it. Then, if we try to send on theperspective.websocket
a runtime error is triggered and it is not an ideal situation to deal with or code against. I would like to propose that theWebSocketClient
allow the client to add its own event handlers, at least for 3/4 events... something like (probably botched TS syntax below, but you get the idea):Potential Solutions:
The only drawbacks I see are if the WS is to be recycled, before it is nil'd out, all handlers should be removed.
Adding this would allow us to better manage how we interact with the state -- given we'll be notified of what the current state of the websocket is at any given moment.
The text was updated successfully, but these errors were encountered: