Enable and disable the IoT demo spawn/kill buttons.
Previous commit changed DOM fragment representation to use strings instead of Seal'd quasi-sexprs, and so eliminated any distinction between textually-identical DOM fragments in the dataspace. This patch disables the "spawn" buttons for components in the IoT demo to avoid (mostly harmless) duplication of actor instances. It also demonstrates use of react{} outside a *lexically*-enclosing actor{}.
This commit is contained in:
parent
dede7f08a7
commit
4a2c8147aa
|
@ -183,12 +183,32 @@ function spawnFailureMonitor() {
|
|||
|
||||
function spawnChaosMonkey() {
|
||||
actor {
|
||||
react {
|
||||
on message jQueryEvent('#spawn-power-draw-monitor', 'click', _) {
|
||||
spawnPowerDrawMonitor();
|
||||
monitorComponent('power draw monitor',
|
||||
'#spawn-power-draw-monitor',
|
||||
'#kill-power-draw-monitor',
|
||||
spawnPowerDrawMonitor);
|
||||
monitorComponent('stove switch',
|
||||
'#spawn-stove-switch',
|
||||
'#kill-stove-switch',
|
||||
spawnStoveSwitch);
|
||||
}
|
||||
on message jQueryEvent('#spawn-stove-switch', 'click', _) {
|
||||
spawnStoveSwitch();
|
||||
|
||||
function monitorComponent(name, spawnButtonSelector, killButtonSelector, spawnFunction) {
|
||||
var jSpawnButtons = $(spawnButtonSelector);
|
||||
var jKillButtons = $(killButtonSelector);
|
||||
react {
|
||||
during componentPresent(name) {
|
||||
do {
|
||||
jSpawnButtons.prop('disabled', true);
|
||||
jKillButtons.prop('disabled', false);
|
||||
}
|
||||
finally {
|
||||
jSpawnButtons.prop('disabled', false);
|
||||
jKillButtons.prop('disabled', true);
|
||||
}
|
||||
}
|
||||
on message jQueryEvent(spawnButtonSelector, 'click', _) {
|
||||
spawnFunction();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue