From 307019bdbbf9b27e8c28fbc7fd5ed0de4cb2848b Mon Sep 17 00:00:00 2001
From: Janne Alatalo <janne.alatalo@jamk.fi>
Date: Mon, 24 Sep 2018 16:43:15 +0300
Subject: [PATCH] Fix another potential race condition

---
 src/App.js | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/App.js b/src/App.js
index 651dfb8..19f086b 100644
--- a/src/App.js
+++ b/src/App.js
@@ -27,8 +27,10 @@ class App extends Component {
     let width = window.innerWidth;
     let height = window.innerHeight;
     this.state = { lam_points: Map(), mapSize: { width, height } };
-    get_lam_points("http://tie.digitraffic.fi", this.update_state.bind(this));
-    connect_lam_ws("ws://tie.digitraffic.fi", this.update_state.bind(this));
+    get_lam_points("http://tie.digitraffic.fi", this.update_state.bind(this))
+      .then(() => {
+        connect_lam_ws("ws://tie.digitraffic.fi", this.update_state.bind(this));
+      })
     this.handleResize = this.handleResize.bind(this);
   }
 
-- 
GitLab