Refactor
This commit is contained in:
@@ -12,19 +12,12 @@ import {
|
||||
makeConnectionStateEvent,
|
||||
makePublishEvent,
|
||||
removeConnection,
|
||||
updateAvailable,
|
||||
updateAvailable
|
||||
} from '../../events'
|
||||
|
||||
export class ConnectionManager {
|
||||
private connections: {[s: string]: DataSource<any>} = {}
|
||||
|
||||
public manageConnections() {
|
||||
backendEvents.subscribe(addMqttConnectionEvent, this.handleConnectionRequest)
|
||||
backendEvents.subscribe(removeConnection, (connectionId: string) => {
|
||||
this.removeConnection(connectionId)
|
||||
})
|
||||
}
|
||||
|
||||
private handleConnectionRequest = (event: AddMqttConnection) => {
|
||||
const connectionId = event.id
|
||||
|
||||
@@ -61,6 +54,13 @@ export class ConnectionManager {
|
||||
})
|
||||
}
|
||||
|
||||
public manageConnections() {
|
||||
backendEvents.subscribe(addMqttConnectionEvent, this.handleConnectionRequest)
|
||||
backendEvents.subscribe(removeConnection, (connectionId: string) => {
|
||||
this.removeConnection(connectionId)
|
||||
})
|
||||
}
|
||||
|
||||
public removeConnection(conenctionId: string) {
|
||||
const connection = this.connections[conenctionId]
|
||||
if (connection) {
|
||||
|
||||
Reference in New Issue
Block a user