-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…e-no-dvr-slides-issue Revert "Revert "fix(FEC-13766): last active slide does not appear on dual screen""
- Loading branch information
Showing
4 changed files
with
85 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
interface DataAggregatorProps { | ||
throttleTimeout?: number; | ||
onTimeoutFn: (data: any) => void; | ||
} | ||
|
||
export class DataAggregator { | ||
private _data: any[] = []; | ||
private _timerId: NodeJS.Timeout | null = null; | ||
private _throttleTimeout = 250; | ||
private _onTimeoutFn: (data: any) => void; | ||
|
||
constructor(options: DataAggregatorProps) { | ||
this._onTimeoutFn = options.onTimeoutFn; | ||
} | ||
|
||
public addData(data: any): void { | ||
this._data.push(data); | ||
if (!this._timerId) { | ||
this._timerId = setTimeout(() => { | ||
this._useData(); | ||
this._clearData(); | ||
this._timerId = null; | ||
}, this._throttleTimeout); | ||
} | ||
} | ||
|
||
private _useData(): void { | ||
if (this._data.length > 0) { | ||
this._onTimeoutFn(this._data); | ||
} | ||
} | ||
|
||
private _clearData(): void { | ||
this._data = []; | ||
} | ||
|
||
public destroy(): void { | ||
if (this._timerId) { | ||
clearTimeout(this._timerId); | ||
this._clearData(); | ||
} | ||
} | ||
} |
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