mirror of
https://github.com/vale981/event-pubsub
synced 2025-03-06 01:51:39 -05:00
36 lines
631 B
JavaScript
36 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'
|
||
|
);
|