example.js 416 B

12345678910111213141516171819
  1. var emitter = require('./index')()
  2. emitter.on('*', function () {
  3. console.log('all events emitted', this.event)
  4. })
  5. emitter.on('example', function () {
  6. console.log('example event emitted')
  7. })
  8. emitter.emit('example')
  9. emitter.on('demo', function () {
  10. console.log('multiple events with `demo` namespace emitted', this.event)
  11. })
  12. emitter.emit('demo:cool')
  13. emitter.emit('demo:awesome')
  14. emitter.emit('demo:great')