From fff81d53db0ba00b232938651fa030b15ed17f67 Mon Sep 17 00:00:00 2001 From: Dylan Praul Date: Thu, 8 Aug 2019 17:55:34 -0400 Subject: [PATCH] geoData can be a promise to resolve --- src/js/geomap.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/js/geomap.js b/src/js/geomap.js index ade3246..8394b00 100644 --- a/src/js/geomap.js +++ b/src/js/geomap.js @@ -21,7 +21,7 @@ export class Geomap { /** * Contents of TopoJSON file. If specified, geofile is ignored. * - * @type {object|null} + * @type {Promise|object|null} */ geoData: null, height: null, @@ -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() {