From 50167a686ae251b69b87efff76e1fa591a1b1dc3 Mon Sep 17 00:00:00 2001 From: casperlamboo Date: Thu, 21 Apr 2016 15:17:38 +0200 Subject: [PATCH] added boxes changed event --- src/doodle3dmanager.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/doodle3dmanager.js b/src/doodle3dmanager.js index 28dc58f..8e24051 100644 --- a/src/doodle3dmanager.js +++ b/src/doodle3dmanager.js @@ -58,14 +58,22 @@ export default class Doodle3DManager extends EventDispatcher { const newBoxes = boxes.filter(box => knownIPsClient.indexOf(box.localip) === -1); const removedBoxes = this.boxes.filter(box => knownIPsServer.indexOf(box.boxData.localip) === -1); + let changed = false; for (const boxData of newBoxes) { const box = new Doodle3DAPI(boxData); - this._addBox(box); + + changed = true; } for (const box of removedBoxes) { this._removeBox(box); + + changed = true; + } + + if (changed) { + this.dispatchEvent({ type: 'boxeschanged', boxes: this.boxes }); } }