Skip to content

mybrewery/eventbus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Eventbus

Concept

https://en.wikipedia.org/wiki/Publish–subscribe_pattern

Using

var eventbus = new Eventbus;

/*subscribing for events*/
eventbus.sub("hello", function(){
  console.log("hello!");
});

eventbus.sub("hello", function(data){
  console.log(["hello", data.user].join(" "));
});

eventbus.sub("bye", function(data){
  console.log("buvaite");
});

/*dispatching events and passing data to subscribers*/
eventbus.pub("hello", {
  user: "Elvis"
});
// "hello!"
// "hello Elvis"

eventbus.pub("bye");
// "buvaite"
		

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published