From 65088708bd3d2ab0eb1b7663fe7de40ca15f1981 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Thu, 21 Apr 2016 15:17:10 +0200 Subject: [PATCH] added alive check in doodle3dapi --- src/doodle3dapi.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/doodle3dapi.js b/src/doodle3dapi.js index 374f741..42b6d33 100644 --- a/src/doodle3dapi.js +++ b/src/doodle3dapi.js @@ -81,11 +81,15 @@ export default class extends EventDispatcher { async _update () { while (this.autoUpdate) { - try { - this.state = await this.info.status(); + if (this.alive) { + try { + this.state = await this.info.status(); - this.dispatchEvent({ type: 'update', state: this.state }); - } catch(error) { + this.dispatchEvent({ type: 'update', state: this.state }); + } catch(error) { + await this.checkAlive(); + } + } else { await this.checkAlive(); }