Browser cross-tab events library.
Allow to emit events that will be dispatched to all other tabs from that domain opened.
$ bower install StreetStrider/XTab
<script src='path/to/XTab.js'></script>
XTab.on('meow', function handler (cat) { ... });
XTab.once('meow', function onceHandler (onlyCat) { ... });
XTab.emit('meow', 'Boris');
function handler1 () { ... };
function handler2 () { ... };
function handler3 () { ... };
XTab.on('meow', handler1);
XTab.on('meow', handler2);
XTab.on('meow', handler3);
Handlers will be triggered in straight order of assignment.
XTab.off('meow', handler1); // removes only handler1
XTab.off('meow'); // removes all handlers for meow event
XTab.off(); // removes all handlers
XTab.once('woff', function run () { ... }); // triggered only once
XTab.emit('woff');
XTab.emit('woff'); // no effect
MIT. Copyright © 2012 – 2014 StreetStrider.