Skip to content

Commit 945216f

Browse files
committed
switch to bacon based interval
1 parent 71fe6a6 commit 945216f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

sdk/smx.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class SMXStage {
8181
private debug = true;
8282
private _config: SMXConfig | null = null;
8383
private panelTestMode = PanelTestMode.Off;
84-
private testModeIntervalHandle: number | null = null;
84+
private cancelTestModeInterval: Bacon.Unsub | null = null;
8585

8686
public get config() {
8787
return this._config?.config || null;
@@ -243,9 +243,9 @@ export class SMXStage {
243243
// We don't want to send the "Off" command multiple times, so only send it if
244244
// it's currently activated
245245
if (this.panelTestMode !== PanelTestMode.Off) {
246-
if (this.testModeIntervalHandle !== null) {
247-
clearInterval(this.testModeIntervalHandle);
248-
this.testModeIntervalHandle = null;
246+
if (this.cancelTestModeInterval) {
247+
this.cancelTestModeInterval();
248+
this.cancelTestModeInterval = null;
249249
}
250250
// Turn off panel test mode, and send "Off" event
251251
this.panelTestMode = mode;
@@ -274,10 +274,10 @@ export class SMXStage {
274274

275275
// The Panel Test Mode command needs to be resent approximately every second, or else the stage will
276276
// auto time out and turn off Panel Test Mode itself
277-
this.testModeIntervalHandle = setInterval(() => {
277+
this.cancelTestModeInterval = Bacon.interval(1000, null).subscribe(() => {
278278
console.log("Test Mode Push Interval");
279279
this.events.output$.push(Uint8Array.of(API_COMMAND.SET_PANEL_TEST_MODE, char2byte(" "), mode, char2byte("\n")));
280-
}, 1000);
280+
});
281281
}
282282
}
283283

0 commit comments

Comments
 (0)