mirror of
https://github.com/vale981/event-pubsub
synced 2025-03-04 17:11:38 -05:00
Update README.md
Starting examples
This commit is contained in:
parent
958c123155
commit
425ccc5afd
1 changed files with 59 additions and 2 deletions
61
README.md
61
README.md
|
@ -1,4 +1,61 @@
|
|||
event-pubsub
|
||||
Event PubSub
|
||||
============
|
||||
|
||||
Event Pubsub for Javascript will work in node js or browser
|
||||
Pubsub events for Node and the browser allowing event scoping and multiple scopes.
|
||||
Easy for any developer level. No frills, just high speed pubsub events!
|
||||
|
||||
---
|
||||
### Basic Examples
|
||||
---
|
||||
#### Node
|
||||
|
||||
var events = new require('../../event-pubsub.js')();
|
||||
|
||||
events.on(
|
||||
'hello',
|
||||
function(data){
|
||||
console.log('hello event recieved ', data);
|
||||
}
|
||||
);
|
||||
|
||||
events.on(
|
||||
'*',
|
||||
function(type){
|
||||
console.log('Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments);
|
||||
}
|
||||
);
|
||||
|
||||
/************************************\
|
||||
* trigger events for testing
|
||||
* **********************************/
|
||||
events.trigger(
|
||||
'hello',
|
||||
'world'
|
||||
);
|
||||
|
||||
#### Browser
|
||||
##### HTML
|
||||
|
||||
var events = new require('../../event-pubsub.js')();
|
||||
|
||||
events.on(
|
||||
'hello',
|
||||
function(data){
|
||||
console.log('hello event recieved ', data);
|
||||
}
|
||||
);
|
||||
|
||||
events.on(
|
||||
'*',
|
||||
function(type){
|
||||
console.log('Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments);
|
||||
}
|
||||
);
|
||||
|
||||
/************************************\
|
||||
* trigger events for testing
|
||||
* **********************************/
|
||||
events.trigger(
|
||||
'hello',
|
||||
'world'
|
||||
);
|
||||
|
|
Loading…
Add table
Reference in a new issue