Way to much fixes and improvements

This commit is contained in:
Pieter Vander Vennet 2020-09-02 11:37:34 +02:00
parent e68d9d99a5
commit 5ed0bb431c
41 changed files with 1244 additions and 402 deletions

View file

@ -36,9 +36,8 @@ export class UIEventSource<T>{
});
for (const possibleSource of possibleSources) {
possibleSource.addCallback(() => {
possibleSource?.addCallback(() => {
sink.setData(source.data?.data);
})
}
@ -86,5 +85,25 @@ export class UIEventSource<T>{
}
return this;
}
public stabilized(millisToStabilize) : UIEventSource<T>{
const newSource = new UIEventSource<T>(this.data);
let currentCallback = 0;
this.addCallback(latestData => {
currentCallback++;
const thisCallback = currentCallback;
window.setTimeout(() => {
if(thisCallback === currentCallback){
newSource.setData(latestData);
}
}, millisToStabilize)
});
return newSource;
}
}