Fix refreshTargets race condition

This commit is contained in:
Paul Kaplan 2017-05-16 09:20:52 -04:00
parent 8f45045af0
commit 2c4361b830

View file

@ -645,7 +645,6 @@ class Runtime extends EventEmitter {
* inactive threads after each iteration.
*/
_step () {
this._refreshTargets = false;
// Find all edge-activated hats, and add them to threads to be evaluated.
for (const hatType in this._hats) {
if (!this._hats.hasOwnProperty(hatType)) continue;
@ -663,7 +662,10 @@ class Runtime extends EventEmitter {
// @todo: Only render when this.redrawRequested or clones rendered.
this.renderer.draw();
}
if (this._refreshTargets) this.emit(Runtime.TARGETS_UPDATE);
if (this._refreshTargets) {
this.emit(Runtime.TARGETS_UPDATE);
this._refreshTargets = false;
}
}
/**