gazette

1.0.1 • Public • Published

   ,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() {
  console.log(arguments);
});
 
gazette.publish("foo", ["foo", "bar"]); //=> ["foo", "bar"]
 

Infuse something with pubsub

 
var sample = require("gazette").infuse({
  greeting: "Hello"
});
 
sample.subscribe("hello", function(name) {
  console.log(this.greeting + "" + name); 
});
 
sample.publish("hello", "Nate"); //=> "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() { 
    console.log("Event fired. Arguments: ", arguments); 
  });
  
  $.publish("event", ["foo", "bar"]); //=> "Event fired. Arguments: ["foo", "bar"]"
 

Readme

Keywords

Package Sidebar

Install

npm i gazette

Weekly Downloads

7

Version

1.0.1

License

none

Last publish

Collaborators

  • nhunzaker