Autoload OH if country code is not yet loaded

This commit is contained in:
Pieter Vander Vennet 2020-10-11 22:44:58 +02:00
parent c9478c100a
commit feab5a19b3
4 changed files with 19 additions and 5 deletions

View file

@ -113,12 +113,16 @@ export class UIEventSource<T>{
return newSource;
}
public static Chronic(millis: number):UIEventSource<Date>{
public static Chronic(millis: number, asLong: () => boolean = undefined): UIEventSource<Date> {
const source = new UIEventSource<Date>(undefined);
function run() {
source.setData(new Date());
window.setTimeout(run, millis);
if (asLong === undefined || asLong()) {
window.setTimeout(run, millis);
}
}
run();
return source;