From ee04fdb8e66c7556f8eafebbd940c2e0f310f5c5 Mon Sep 17 00:00:00 2001 From: GT Team Date: Thu, 17 Mar 2022 13:23:43 +0100 Subject: [PATCH] Allow to retrieve connection state --- projects/ngx-mqtt/src/lib/mqtt.service.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/projects/ngx-mqtt/src/lib/mqtt.service.ts b/projects/ngx-mqtt/src/lib/mqtt.service.ts index a82d794..131f7b6 100644 --- a/projects/ngx-mqtt/src/lib/mqtt.service.ts +++ b/projects/ngx-mqtt/src/lib/mqtt.service.ts @@ -102,10 +102,16 @@ export class MqttService { public get onSuback(): EventEmitter { return this._onSuback; } + + /** An actual connection state **/ + public get connectionState(): MqttConnectionState { + return this.state.value; + } + /** a map of all mqtt observables by filter */ public observables: { [filterString: string]: Observable } = {}; /** the connection state */ - public state: Subject = new BehaviorSubject(MqttConnectionState.CLOSED); + public state: BehaviorSubject = new BehaviorSubject(MqttConnectionState.CLOSED); /** an observable of the last mqtt message */ public messages: Subject = new Subject();