Merge pull request #636 from fsih/deleteMonitors

Update monitors when deleting or renaming variables
This commit is contained in:
DD Liu 2017-07-17 11:06:29 -04:00 committed by GitHub
commit 912e7daa81

View file

@ -4,6 +4,7 @@ const Blocks = require('./blocks');
const Variable = require('../engine/variable');
const List = require('../engine/list');
const uid = require('../util/uid');
const {Map} = require('immutable');
/**
* @fileoverview
@ -161,6 +162,21 @@ class Target extends EventEmitter {
const variable = this.variables[id];
if (variable.id === id) {
variable.name = newName;
if (this.runtime) {
const blocks = this.runtime.monitorBlocks;
blocks.changeBlock({
id: id,
element: 'field',
name: 'VARIABLE',
value: id
}, this.runtime);
this.runtime.requestUpdateMonitor(Map({
id: id,
params: blocks._getBlockParams(blocks.getBlock(variable.id))
}));
}
}
}
}
@ -172,6 +188,9 @@ class Target extends EventEmitter {
deleteVariable (id) {
if (this.variables.hasOwnProperty(id)) {
delete this.variables[id];
if (this.runtime) {
this.runtime.requestRemoveMonitor(id);
}
}
}