fix data sharing race condition

This commit is contained in:
Matt Walsh
2020-10-20 20:04:51 -05:00
parent c4e8ef6a14
commit 98e01688ae
8 changed files with 285 additions and 8 deletions

View File

@@ -20,6 +20,7 @@ class WeatherDisplay {
this.data = undefined;
this.loadingStatus = STATUS.loading;
this.name = name?name:elemId;
this.getDataCallbacks = [];
// default navigation timing
this.timing = {
@@ -126,6 +127,14 @@ class WeatherDisplay {
return true;
}
// return any data requested before it was available
getDataCallback() {
// call each callback
this.getDataCallbacks.forEach(fxn => fxn(this.data));
// clear the callbacks
this.getDataCallbacks = [];
}
drawCanvas() {
// stop all gifs
this.gifs.forEach(gif => gif.pause());