Skip to content

Commit b378091

Browse files
committed
refactor: add jsdoc to unsubscribe method
1 parent 63262ab commit b378091

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/WorkflowManager.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const WorkflowManager: FC<WorkflowManagerProps> = ({
2323
const mqttInstance = connect(brokerUrl, options);
2424

2525
mqttInstance.on('connect', () => {
26+
if (status !== 'connected') setStatus('connected');
2627
setStatus('connected');
2728
});
2829

@@ -31,15 +32,16 @@ export const WorkflowManager: FC<WorkflowManagerProps> = ({
3132
});
3233

3334
mqttInstance.on('offline', () => {
34-
setStatus('offline');
35+
if (status !== 'offline') setStatus('offline');
3536
});
3637

3738
mqttInstance.on('error', () => {
38-
setStatus('error');
39+
if (status !== 'error') setStatus('error');
3940
invariant(false, ERROR_MESSAGES.ERROR_OCURRED);
4041
});
4142

4243
mqttInstance.on('reconnect', () => {
44+
if (status !== 'reconnecting') setStatus('reconnecting');
4345
setStatus('reconnecting');
4446
});
4547

@@ -51,7 +53,7 @@ export const WorkflowManager: FC<WorkflowManagerProps> = ({
5153
invariant(false, ERROR_MESSAGES.FAILED_TO_CONNECT);
5254
}
5355
}
54-
}, [brokerUrl, options, client]);
56+
}, [brokerUrl, options, client, status]);
5557

5658
useEffect(() => {
5759
init();

0 commit comments

Comments
 (0)