eBus

An anonymous publish/subscribe system. Provides for anonymous asynchronous communication between multiple modules. Also has a synchronous call feature to request values.

by Hans PUFAL

HTML

Implements a publish/scubscribe system

JavaScript

(function eBus() { 'use strict';
/* eBus        : an anonymous publish/subscribe system
   Version     : 1.01  2012-10-22
   Author      : Hans B PUFAL : [email protected]
   Licence     : (c) 2012 under http://www.opensource.org/licenses/mit-license.html
   Repository  : http://jsfiddle.net/jstoolsmith/X2GWS
   Compression : 1899 chars with Packer 3.1 @ http://compressorrater.thruhere.net
//----------------------------------------------------------------------------------------
// http://jsfiddle.net/jstoolsmith/X2GWS v1.01 (c) 2012-10-22 Hans B PUFAL, MIT license
eval(function(p,a,c,k,e,r){e=function(c){return(c<62?'':e(parseInt(c/62)))+((c=c%62)>35?String.fromCharCode(c+29):c.toString(36))};if('0'.replace(0,e)==0){while(c--)r[e(c)]=k[c];k=[function(e){return r[e]||e}];e=function(){return'[3-9l-rt-vxyA-M]'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('(7 5(){\'use strict\';9 e={};C.implement([7 j(b,a){9 c=(e[b]||[]).n();(a=(o.6>2||!v.x(a))?[].n.p(o,1):a.n()).y({D:b,E:4});4!==5&&e.3&&5.8(\'3\',\'pub\',c,a);c.6&&F.G(7 d(){a[0].r=c[0][1].H(c[0][0],a);e.3&&5.8(\'3\',\'8 I\',c[0],a);a[0].r!==t&&(c.shift(),c.6)&&F.G(d,0)},0);u c.6},7 k(b,a){9 c=e[b]||[];(a=(o.6>2||!v.x(a))?[].n.p(o,1):a.n()).y({D:b,E:4});4!==5&&e.3&&5.8(\'3\',\'req\',c,a);l(9 d=[],f=c.6;f--&&a[0].r!==t;){(a[0].r=c[f][1].H(c[f][0],a))!==J&&d.push({subscriber:c[f][0],A:a[0].A});e.3&&5.8(\'3\',\'request I\',c[0],a)}u d[1]?d:d[0]?d[0].A:J},7 g(b,a){9 c=true;q(v.x(b))l(9 d=b.6;d--;)m b[d]===\'7\'&&(c&=g.p(4,(b[d].toString().match(/^7\\s+([a-z$_][\\w$]+)/i)||[0,\'\'])[1],b[d]));B q(m b===\'object\'){l(d in b)b.hasOwnProperty(d)&&m b[d]===\'7\'&&(c&=g.p(4,d,b[d]))}B{m a===\'K\'&&(a=4[a]);m a!==\'7\'&&e.3&&5.8(\'3\',\'typeError L callback\',b,4,a);l(9 f,h=(e[b]||[]).6;h--;)q((f=e[b][h])[0]===4&&f[1]===a){e.3&&5.8(\'3\',\'L dup\',b,4,a);c=!1}c&&(e[b]||(e[b]=[])).y([4,a]);4!==5&&e.3&&5.8(\'3\',\'sub \'+e,b)}u c},7 i(b,a){q(o.6===0)l(9...