make it possible for VM to emit update monitors action

This commit is contained in:
DD Liu 2017-05-09 12:10:11 -04:00
parent 26a5098347
commit 35a208d1d3
2 changed files with 19 additions and 0 deletions

View file

@ -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.

View file

@ -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);