From b3f96efb33d7fc99500147d336ead1536b6b24e9 Mon Sep 17 00:00:00 2001 From: Alon Levy Date: Sun, 26 Oct 2014 22:25:29 +0200 Subject: introduce signal, start using in history; use consts for signal name introduces two new modules: scripts/consts.js scripts/signal.js signal is a thin wrapper for jquery('window').on and jquery('window').trigger, which seems like an adaquete signal library - there are faster things around, but why introduce another dependency. --- scripts/signal.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 scripts/signal.js (limited to 'scripts/signal.js') diff --git a/scripts/signal.js b/scripts/signal.js new file mode 100644 index 00000000..49c5afd3 --- /dev/null +++ b/scripts/signal.js @@ -0,0 +1,22 @@ +/* + * Signal/slot (i.e. blackboard pattern) for rhizi. + * + * This is a thin wrapper over jquery right now. + * But just keeping it here to make any future change of implementation slightly + * easier. + */ + +define('signal', ['jquery'], function($) { + function slot(name, handler) { + $(window).on(name, function(e, args) { + handler(args); + }); + }; + function signal(name, obj) { + $(window).trigger(name, obj); + } + return { + 'slot': slot, + 'signal': signal + }; +}) -- cgit v1.3.1