From 35a208d1d380e720a5a83a8e783e51c028482523 Mon Sep 17 00:00:00 2001 From: DD Liu Date: Tue, 9 May 2017 12:10:11 -0400 Subject: [PATCH] make it possible for VM to emit update monitors action --- src/engine/runtime.js | 16 ++++++++++++++++ src/virtual-machine.js | 3 +++ 2 files changed, 19 insertions(+) diff --git a/src/engine/runtime.js b/src/engine/runtime.js index 34c008a1e..ae0295f88 100644 --- a/src/engine/runtime.js +++ b/src/engine/runtime.js @@ -233,6 +233,14 @@ class Runtime extends EventEmitter { return 'SPRITE_INFO_REPORT'; } + /** + * Event name for monitors update. + * @const {string} + */ + static get MONITORS_UPDATE () { + return 'MONITORS_UPDATE'; + } + /** * How rapidly we try to step threads by default, in ms. */ @@ -819,6 +827,14 @@ class Runtime extends EventEmitter { this.emit(Runtime.SPRITE_INFO_REPORT, target.toJSON()); } + /** + * Emit a monitor update. + * @param {!Array} monitors Array of all monitors + */ + monitorsUpdate (monitors) { + this.emit(Runtime.MONITORS_UPDATE, monitors); + } + /** * Get a target by its id. * @param {string} targetId Id of target to find. diff --git a/src/virtual-machine.js b/src/virtual-machine.js index c56e289c0..ed1ab98af 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -55,6 +55,9 @@ class VirtualMachine extends EventEmitter { instance.runtime.on(Runtime.SPRITE_INFO_REPORT, spriteInfo => { instance.emit(Runtime.SPRITE_INFO_REPORT, spriteInfo); }); + instance.runtime.on(Runtime.MONITORS_UPDATE, spriteInfo => { + instance.emit(Runtime.MONITORS_UPDATE, spriteInfo); + }); this.blockListener = this.blockListener.bind(this); this.flyoutBlockListener = this.flyoutBlockListener.bind(this);