From dff333b558cb29f1c6fa6d13ee4239a9bc0a81a6 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Tue, 27 Jan 2015 11:53:45 +0200 Subject: client: remove state variable in node view and use bacon property instead --- src/client/view/graph_view.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'src/client/view/graph_view.js') diff --git a/src/client/view/graph_view.js b/src/client/view/graph_view.js index 2315eb10..fe18ed5c 100644 --- a/src/client/view/graph_view.js +++ b/src/client/view/graph_view.js @@ -147,12 +147,11 @@ function GraphView(spec) { }); function showNodeInfo(node) { - var closed = false; + var diffBusUnsubscribe; util.assert(!temporary, "cannot showNodeInfo on a temporary graph"); view.node_info.on_save(function(e, form_data) { - closed = true; graph.update_node(node, form_data, function() { var old_type = node.type, new_type = form_data.type; @@ -162,12 +161,25 @@ function GraphView(spec) { return false; }); - graph.diffBus.onValue(function (diff) { - if (closed || !model_diff.is_attr_diff(diff)) { - return Bacon.noMore; + diffBusUnsubscribe = graph.diffBus.onValue(function (diff) { + if (!model_diff.is_attr_diff(diff)) { + console.log('node_edit listener for ' + node.id + ': ignoring diff'); + return; } view.node_info.show(node); }); + view.node_info.isOpenProperty.skip(1).onValue(function (open) { + var ISaidNoMore = false; + if (ISaidNoMore) { + console.log('MAYDAY MAYDAY why am I here??'); + } + if (!open) { + console.log('node_edit listener for ' + node.id + ': shutting down'); + diffBusUnsubscribe(); + ISaidNoMore = true; + return Bacon.noMore; + } + }) view.node_info.on_delete(function() { var topo_diff = model_diff.new_topo_diff({ -- cgit v1.3.1