,ad8888ba,
d8"' `"8b ,d ,d
d8' 88 88
88 ,adPPYYba, 888888888 ,adPPYba, MM88MMM MM88MMM ,adPPYba,
88 88888 "" `Y8 a8P" a8P_____88 88 88 a8P_____88
Y8, 88 ,adPPPPP88 ,d8P' 8PP""""""" 88 88 8PP"""""""
Y8a. .a88 88, ,88 ,d8" "8b, ,aa 88, 88, "8b, ,aa
`"Y88888P" `"8bbdP"Y8 888888888 `"Ybbd8"' "Y888 "Y888 `"Ybbd8"'
Add pubsub to anything
General Use
var gazette = require("gazette");
gazette.subscribe("foo", function(args) {
console.log(args);
});
gazette.publish("foo", "bar");
Infuse something with pubsub
var sample = require("gazette").infuse({
greeting: "Hello"
});
sample.subscribe("hello", function(args) {
console.log(this.greeting + ", " + args.toString());
});
sample.publish("hello", "Nate");
or infuse an existing object
var gazette = require("./gazette");
, sample = { greeting: "Hello" };
gazette.infuse(sample);
Ender.js
Simple add gazette
to your build
$.subscribe("hello", function() {
console.log("greetings")
});
$.publish("hello");
$("#dom-element").subscribe("event", function(args) {
console.log("Event fired. Arguments: ", args);
});
$.publish("event", ["foo", "bar"]);