Skip to content

Commit

Permalink
geoData can be a promise to resolve
Browse files Browse the repository at this point in the history
  • Loading branch information
dpraul committed Aug 8, 2019
1 parent edff38f commit fff81d5
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/js/geomap.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Geomap {
/**
* Contents of TopoJSON file. If specified, geofile is ignored.
*
* @type {object|null}
* @type {Promise<object>|object|null}
*/
geoData: null,
height: null,
Expand Down Expand Up @@ -131,11 +131,12 @@ export class Geomap {
self.update();
};

if (self.properties.geoData) {
drawGeoData(self.properties.geoData);
} else {
d3JSONFetch(self.properties.geofile).then(geo => drawGeoData(geo));
}
Promise.resolve(() => {
if (self.properties.geoData) {
return self.properties.geoData;
}
return d3JSONFetch(self.properties.geofile);
}).then(geo => drawGeoData(geo));
}

update() {
Expand Down

0 comments on commit fff81d5

Please sign in to comment.