From 42eacd877b5564961c2dcc491f5d4b7d62f4e753 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sat, 29 Nov 2014 22:28:29 +0200 Subject: use Bacon instead of signal See https://github.com/baconjs/bacon.js Usage right now: we have rz_bus to hold global busses: - names: for autosuggest - ui busses: - ui_key - ui_input The events are objects with {where: from consts, keys/input} (could maybe just use the events and rely on the target element class/id) And graph has it's own bus: graph.diffBus (camelcase probably not the right style - will fix in later commit) To publish to a bus you use push. To insert another stream to a bus you use plug. To listen to a bus you use onValue (you can use subscribe too to get errors and end of stream event, but we don't use that yet). This allows usage of map, filter, flatMap, see github repo for cool examples. --- src/textanalysis.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/textanalysis.js') diff --git a/src/textanalysis.js b/src/textanalysis.js index 9114bbff..f1277050 100644 --- a/src/textanalysis.js +++ b/src/textanalysis.js @@ -1,7 +1,7 @@ "use strict"; -define(['rz_core', 'model/core', 'model/util', 'model/diff', 'signal', 'consts'], -function(rz_core, model_core, model_util, model_diff, signal, consts) { +define(['rz_core', 'model/core', 'model/util', 'model/diff', 'rz_bus', 'consts'], +function(rz_core, model_core, model_util, model_diff, rz_bus, consts) { var typeindex = 0; var nodetypes = ["person", "club", "skill", "interest", "third-internship-proposal", "internship"]; @@ -466,7 +466,7 @@ var textAnalyser = function (newtext, finalize) { return ret; }; -function init() +function init(graph) { function onNodeAdded(diff) { if (!diff || !diff.nodes || diff.nodes.added) { @@ -480,8 +480,8 @@ function init() function onSuggestedNameAdd(names) { names.map(String.toLowerCase).forEach(autoSuggestAddName); } - signal.slot(consts.APPLIED_GRAPH_DIFF, onNodeAdded); - signal.slot(consts.SUGGESTED_NAME_ADD, onSuggestedNameAdd); + graph.diffBus.onValue(onNodeAdded); + rz_bus.names.onValue(onSuggestedNameAdd); } return { -- cgit v1.3.1