mirror of
https://github.com/thomasnordquist/MQTT-Explorer.git
synced 2026-09-12 09:35:01 +00:00
42 lines
683 B
TypeScript
42 lines
683 B
TypeScript
interface InternalState {
|
|
connecting: boolean
|
|
connected: boolean
|
|
error?: Error
|
|
}
|
|
|
|
export class DataSourceState {
|
|
private state: InternalState = {
|
|
error: undefined,
|
|
connected: false,
|
|
connecting: false
|
|
}
|
|
|
|
public setConnected(connected: boolean) {
|
|
this.state = {
|
|
error: undefined,
|
|
connected: connected,
|
|
connecting: false
|
|
}
|
|
}
|
|
|
|
public setError(error: Error) {
|
|
this.state = {
|
|
error: error,
|
|
connected: false,
|
|
connecting: false
|
|
}
|
|
}
|
|
|
|
public setConnecting() {
|
|
this.state = {
|
|
error: undefined,
|
|
connected: false,
|
|
connecting: true
|
|
}
|
|
}
|
|
|
|
public toJSON() {
|
|
return this.state
|
|
}
|
|
}
|