Skip to content

Commit

Permalink
#112 Check if connectOnCreate in connect/reconnect handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
sclausen committed Sep 5, 2018
1 parent e81d6f2 commit 2bab14f
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/mqtt.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,17 +316,21 @@ export class MqttService {
}

private _handleOnConnect = (e: IOnConnectEvent) => {
Object.keys(this.observables).forEach((filter: string) => {
this.client.subscribe(filter);
});
if (this.options.connectOnCreate === true) {
Object.keys(this.observables).forEach((filter: string) => {
this.client.subscribe(filter);
});
}
this.state.next(MqttConnectionState.CONNECTED);
this._onConnect.emit(e);
}

private _handleOnReconnect = () => {
Object.keys(this.observables).forEach((filter: string) => {
this.client.subscribe(filter);
});
if (this.options.connectOnCreate === true) {
Object.keys(this.observables).forEach((filter: string) => {
this.client.subscribe(filter);
});
}
this.state.next(MqttConnectionState.CONNECTING);
this._onReconnect.emit();
}
Expand Down

0 comments on commit 2bab14f

Please sign in to comment.