Initial commit
[yaffs-website] / node_modules / sparkles / README.md
1 sparkles
2 ========
3
4 [![Build Status](https://travis-ci.org/phated/sparkles.svg?branch=master)](https://travis-ci.org/phated/sparkles)
5
6 Namespaced global event emitter
7
8 ## Usage
9
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
14 ```js
15 var sparkles = require('sparkles')(); // make sure to call the function
16
17 sparkles.on('my-event', function(evt){
18   console.log('my-event handled', evt);
19 });
20
21 sparkles.emit('my-event', { my: 'event' });
22 ```
23
24 ## API
25
26 ### sparkles(namespace)
27
28 Returns an EventEmitter that is shared amongst the provided namespace.  If no namespace
29 is provided, returns a default EventEmitter.
30
31 ### sparkles.exists(namespace);
32
33 Checks whether a namespace exists and returns true or false.
34
35 ## Why the name?
36
37 This is a "global emitter"; shortened: "glitter" but it was already taken; so we got sparkles instead :smile:
38
39 ## License
40
41 MIT