diff options
| author | Alon Levy <alon@pobox.com> | 2014-10-26 22:25:29 +0200 |
|---|---|---|
| committer | Alon Levy <alon@pobox.com> | 2014-10-26 22:25:33 +0200 |
| commit | b3f96efb33d7fc99500147d336ead1536b6b24e9 (patch) | |
| tree | dea2c8bd7fe345a50b048d792a2a3de4430a7b9a /scripts/signal.js | |
| parent | a31a32e4ea03771986192c536141c9f276a41d08 (diff) | |
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.
Diffstat (limited to 'scripts/signal.js')
| -rw-r--r-- | scripts/signal.js | 22 |
1 files changed, 22 insertions, 0 deletions
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 + }; +}) |
