Skip to content

Commit

Permalink
Create TODO for simplifying ws class
Browse files Browse the repository at this point in the history
  • Loading branch information
ugyballoons committed Sep 23, 2024
1 parent a3db7ca commit 59799d1
Showing 1 changed file with 3 additions and 7 deletions.
10 changes: 3 additions & 7 deletions src/js/modules/ws-service-client.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ import ReconnectingWebSocket from "reconnecting-websocket"
import { validate } from "uuid"
import { getWebSockURL } from "./utils"

// TODO - Simplify this class since subscriptionType is no longer rqrd.
// See DM-46449

export class WebsocketClient {
constructor() {
this.connectionID = null
this.latestDataBySubscription = new Map() // Store latest data per subscription
this.ws = new ReconnectingWebSocket(getWebSockURL("ws/data"))
this.ws.onmessage = this.handleMessage.bind(this)
this.ws.onclose = this.handleClose.bind(this)
Expand Down Expand Up @@ -94,7 +96,6 @@ export class WebsocketClient {
data: data.payload,
datestamp: data.datestamp,
}
this.latestDataBySubscription.set(data.dataType, detail) // Store the latest data by subscription type
window.dispatchEvent(new CustomEvent(data.dataType, { detail }))
}
}
Expand All @@ -118,9 +119,4 @@ export class WebsocketClient {
this.ws.send(JSON.stringify(message))
}
}

// New method to retrieve the latest detail for a specific subscription
getLatestDataForSubscription(subscriptionType) {
return this.latestDataBySubscription.get(subscriptionType) || null
}
}

0 comments on commit 59799d1

Please sign in to comment.