-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
69 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
js_modules/dagster-ui/packages/ui-core/src/live-data-provider/LiveDataScheduler.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import type {LiveDataThread} from './LiveDataThread'; | ||
|
||
/** | ||
* This exists as a separate class to allow Jest to mock it | ||
*/ | ||
export class LiveDataScheduler<T> { | ||
private thread: LiveDataThread<T>; | ||
|
||
constructor(thread: LiveDataThread<T>) { | ||
this.thread = thread; | ||
} | ||
private _started = new WeakSet(); | ||
private _stopped = new WeakSet(); | ||
|
||
public scheduleStartFetchLoop(doStart: () => void) { | ||
if (this._started.has(this.thread)) { | ||
return; | ||
} | ||
setTimeout(() => { | ||
doStart(); | ||
this._stopped.delete(this.thread); | ||
}, 50); | ||
} | ||
|
||
public scheduleStopFetchLoop(doStop: () => void) { | ||
if (this._stopped.has(this.thread)) { | ||
return; | ||
} | ||
setTimeout(() => { | ||
doStop(); | ||
this._stopped.delete(this.thread); | ||
}, 50); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters