Skip to content
Snippets Groups Projects
Commit b5a74d22 authored by mathias.chouet's avatar mathias.chouet
Browse files

Progress notifications: every 30ms only

parent aa833bb5
No related branches found
No related tags found
No related merge requests found
......@@ -49,6 +49,9 @@ export abstract class Nub extends ComputeNode implements IObservable {
/** a rough indication of calculation progress, between 0 and 100 */
private _progress: number = 0;
/** allows notifying of progress every X milliseconds only */
private previousNotificationTimestamp = 0;
public constructor(prms: ParamsEquation, dbg: boolean = false) {
super(prms, dbg);
this._children = [];
......@@ -93,11 +96,20 @@ export abstract class Nub extends ComputeNode implements IObservable {
}
/**
* Updates the progress percentage and notifies observers
* Updates the progress percentage and notifies observers,
* at most once per 300ms
*/
protected set progress(v: number) {
this._progress = v;
this.notifyProgressUpdated();
const currentTime = new Date().getTime();
if (
(currentTime - this.previousNotificationTimestamp) > 30
|| v === 100
) {
// console.log(">> notifying !");
this.notifyProgressUpdated();
this.previousNotificationTimestamp = currentTime;
}
}
public get calcType() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment