A simple pub/sub JavaScript utility
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


A dead simple pub/sub javascript library with priority having no third-party dependencies. Inspired by the original work of the AS3 event model which is pretty delicious.

NOTE: This work is over 2.5 years old, could be tuned and is in need of some loving. 

-- start snip --
function foo1(event){
    console.log("foo1 called.")
function foo2(){
    var str = "";
    for(var i=0; i<100000; i++){
        str += "f" + new Date();
    console.log("foo2 called");
function foo3(){
    console.log("foo3 called")  

var myEvent1 = new Subject("PreventDefaultExample");
myEvent1.addEventListener(foo1, 1);
myEvent1.addEventListener(foo2, 1);//will never be called because foo1 preventDefault on event
myEvent1.addEventListener(foo3, 1);//will never be called because foo1 preventDefault on event

var myEvent2 = new Subject("PreventDefaultExample");
myEvent2.addEventListener(foo1, 3);//will be called first due to highest priority
myEvent2.addEventListener(foo2, 2);//will be called second...
myEvent2.addEventListener(foo3, 1);//will be called last
-- end snip --