You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

README.md 1.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <p align="center">
  2. <a href="http://gulpjs.com">
  3. <img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
  4. </a>
  5. </p>
  6. # sparkles
  7. [![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Travis Build Status][travis-image]][travis-url] [![AppVeyor Build Status][appveyor-image]][appveyor-url] [![Coveralls Status][coveralls-image]][coveralls-url] [![Gitter chat][gitter-image]][gitter-url]
  8. Namespaced global event emitter
  9. ## Usage
  10. Sparkles exports a function that returns a singleton `EventEmitter`.
  11. This EE can be shared across your application, whether or not node loads
  12. multiple copies.
  13. ```js
  14. var sparkles = require('sparkles')(); // make sure to call the function
  15. sparkles.on('my-event', function(evt){
  16. console.log('my-event handled', evt);
  17. });
  18. sparkles.emit('my-event', { my: 'event' });
  19. ```
  20. ## API
  21. ### sparkles(namespace)
  22. Returns an EventEmitter that is shared amongst the provided namespace. If no namespace
  23. is provided, returns a default EventEmitter.
  24. ### sparkles.exists(namespace);
  25. Checks whether a namespace exists and returns true or false.
  26. ## Why the name?
  27. This is a "global emitter"; shortened: "glitter" but it was already taken; so we got sparkles instead :smile:
  28. ## License
  29. MIT
  30. [downloads-image]: http://img.shields.io/npm/dm/sparkles.svg
  31. [npm-url]: https://www.npmjs.com/package/sparkles
  32. [npm-image]: http://img.shields.io/npm/v/sparkles.svg
  33. [travis-url]: https://travis-ci.org/gulpjs/sparkles
  34. [travis-image]: http://img.shields.io/travis/gulpjs/sparkles.svg?label=travis-ci
  35. [appveyor-url]: https://ci.appveyor.com/project/gulpjs/sparkles
  36. [appveyor-image]: https://img.shields.io/appveyor/ci/gulpjs/sparkles.svg?label=appveyor
  37. [coveralls-url]: https://coveralls.io/r/gulpjs/sparkles
  38. [coveralls-image]: http://img.shields.io/coveralls/gulpjs/sparkles/master.svg
  39. [gitter-url]: https://gitter.im/gulpjs/gulp
  40. [gitter-image]: https://badges.gitter.im/gulpjs/gulp.svg