https://github.com/upendradevsingh/pubsub
A small JavaScript PubSub framework
https://github.com/upendradevsingh/pubsub
Last synced: 2 months ago
JSON representation
A small JavaScript PubSub framework
- Host: GitHub
- URL: https://github.com/upendradevsingh/pubsub
- Owner: upendradevsingh
- License: mit
- Created: 2016-07-20T01:21:51.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2024-02-26T12:03:17.000Z (about 1 year ago)
- Last Synced: 2025-02-19T14:50:04.381Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pubsub
A small JavaScript PubSub Framework.##Usage
### AMD
define(['Chakmak'], function(Chakmak){
});### commonjs
var Chakmak = require('chakmak').Chakmak;
### Browser default
Add build/chakmak.min.js into your html page.
## Create a Publisher
var pub1 = Chakmak.Publisher.create(); // Creating a empty piblisher
//Creating a publisher with default property and method
var pub2 = Chakmak.Publisher.create(
{
name: 'foo'
},
{
displayName: function(){
return this.name;
}
}
);//Add a new property to Publisher
pub2.addProperty('cart', [
{
name: 'item1',
price: 100
},
{
name: 'item2',
price: 200
}
]);## Create a Subscriber
var sub1 = Chakmak.Publisher.create(
{
template: document.getElementById('content')
},
{
render: function(){this.template.innerHTML = this.publisher.name || '';
}
}
);
// Subscribing to the publisher and an its change event
sub1.subscribe(pub1, 'name:change');