-
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
) * Revert "Revert "fix(FEC-13766): last active slide does not appear on dual screen (#67)"" This reverts commit d7c439f. * fix(FEC-13766): use data-aggregator only for live-without dvr cues
- Loading branch information
1 parent
d5bd3f1
commit 05c3fc2
Showing
4 changed files
with
90 additions
and
8 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