diff --git a/examples/basic.js b/examples/basic.js deleted file mode 100644 index c6143c6..0000000 --- a/examples/basic.js +++ /dev/null @@ -1,57 +0,0 @@ -var events = new require('../event-pubsub.js')(); - -/************************************\ - * - * The events var was instantiated - * as it's own scope - * - * **********************************/ - -events.on( - 'hello', - function(data){ - console.log('hello event recieved ', data); - } -); - -events.on( - 'hello', - function(data){ - console.log('Second handler listening to hello event got',data); - events.trigger( - 'world', - { - type:'myObject', - data:{ - x:'YAY, Objects!' - } - } - ) - } -); - -events.on( - 'world', - function(data){ - console.log('World event got',data); - } -); - -/**********************************\ - * - * Demonstrate * event (on all events) - * remove this for less verbose - * example - * - * ********************************/ -events.on( - '*', - function(type){ - console.log('Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments); - } -); - -events.trigger( - 'hello', - 'world' -); \ No newline at end of file diff --git a/examples/multipleScopes.js b/examples/multipleScopes.js deleted file mode 100644 index 76e9444..0000000 --- a/examples/multipleScopes.js +++ /dev/null @@ -1,90 +0,0 @@ -var pubsub = require('../event-pubsub.js'); - -/************************************\ - * instantiating myEvents scope - * **********************************/ -var myEvents=new pubsub(); - -/************************************\ - * instantiating myEvents2 scope - * **********************************/ -var myEvents2=new pubsub(); - - -/************************************\ - * binding myEvents events - * **********************************/ -myEvents.on( - 'hello', - function(data){ - console.log('myEvents hello event recieved ', data); - } -); - -myEvents.on( - 'hello', - function(data){ - console.log('Second handler listening to myEvents hello event got',data); - myEvents.trigger( - 'world', - { - type:'myObject', - data:{ - x:'YAY, Objects!' - } - } - ) - } -); - -myEvents.on( - 'world', - function(data){ - console.log('myEvents World event got',data); - } -); - -/**********************************\ - * - * Demonstrate * event (on all events) - * remove this for less verbose - * example - * - * ********************************/ -myEvents.on( - '*', - function(type){ - console.log('myEvents Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments); - } -); - -/************************************\ - * binding myEvents2 events - * **********************************/ -myEvents2.on( - 'hello', - function(data){ - console.log('myEvents2 Hello event should never be called ', data); - } -); - -myEvents2.on( - 'world', - function(data){ - console.log('myEvents2 World event ',data); - } -); - - -/************************************\ - * trigger events for testing - * **********************************/ -myEvents.trigger( - 'hello', - 'world' -); - -myEvents2.trigger( - 'world', - 'is round' -); \ No newline at end of file diff --git a/examples/objectScope.js b/examples/objectScope.js deleted file mode 100644 index 9e5c90a..0000000 --- a/examples/objectScope.js +++ /dev/null @@ -1,58 +0,0 @@ -var pubsub = require('../event-pubsub.js'); - -/************************************\ - * - * The events var was instantiated - * as it's own scope - * - * **********************************/ - -var thing={ - id:'my thing' -} -/******************************\ - * - * Create events in the scope - * of the "thing" object - * - * ****************************/ -new pubsub(thing); - -console.log(thing); - -thing.on( - 'getID', - function(){ - console.log('things id is : ',this.id); - } -); - -thing.on( - 'setID', - function(id){ - console.log('setting id to : ',id); - this.id=id; - this.trigger('getID'); - } -); - -/**********************************\ - * - * Demonstrate * event (on all events) - * remove this for less verbose - * example - * - * ********************************/ -thing.on( - '*', - function(type){ - console.log('Catch all detected event type of : ',type, '. List of all the sent arguments ',arguments); - } -); - -thing.trigger('getID'); - -thing.trigger( - 'setID', - 'your thing' -) \ No newline at end of file