mirror of
https://github.com/vale981/event-pubsub
synced 2025-03-05 17:41:40 -05:00
35 lines
631 B
JavaScript
35 lines
631 B
JavaScript
const Events = require('../../es5.js');
|
|
const events = new Events;
|
|
|
|
events.on(
|
|
'hello',
|
|
function(data){
|
|
console.log('hello event recieved ', data);
|
|
events.emit(
|
|
'world',
|
|
{
|
|
type:'myObject',
|
|
data:{
|
|
x:'YAY, Objects!'
|
|
}
|
|
}
|
|
)
|
|
}
|
|
);
|
|
|
|
events.on(
|
|
'*',
|
|
function(type){
|
|
console.log('Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments);
|
|
}
|
|
);
|
|
|
|
events.emit(
|
|
'hello',
|
|
'world'
|
|
);
|
|
|
|
events.emit(
|
|
'hello',
|
|
'again','and again'
|
|
);
|