Namespaced global event emitter
Sparkles exports a function that returns a singleton EventEmitter
.
This EE can be shared across your application, whether or not node loads
multiple copies.
var sparkles = require('sparkles')(); // make sure to call the function
sparkles.on('my-event', function(evt){
console.log('my-event handled', evt);
});
sparkles.emit('my-event', { my: 'event' });
Returns an EventEmitter that is shared amongst the provided namespace. If no namespace is provided, returns a default EventEmitter.
Checks whether a namespace exists and returns true or false.
This is a "global emitter"; shortened: "glitter" but it was already taken; so we got sparkles instead :smile:
MIT
sparkles ======== [![Build Status](https://travis-ci.org/phated/sparkles.svg?branch=master)](https://travis-ci.org/phated/sparkles) Namespaced global event emitter ## Usage Sparkles exports a function that returns a singleton `EventEmitter`. This EE can be shared across your application, whether or not node loads multiple copies. ```js var sparkles = require('sparkles')(); // make sure to call the function sparkles.on('my-event', function(evt){ console.log('my-event handled', evt); }); sparkles.emit('my-event', { my: 'event' }); ``` ## API ### sparkles(namespace) Returns an EventEmitter that is shared amongst the provided namespace. If no namespace is provided, returns a default EventEmitter. ### sparkles.exists(namespace); Checks whether a namespace exists and returns true or false. ## Why the name? This is a "global emitter"; shortened: "glitter" but it was already taken; so we got sparkles instead :smile: ## License MIT
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 19553 | swellard | Move and rename clients | ||
//guest/perforce_software/helix-web-services/main/source/clients/2016.1.0/javascript/node_modules/sparkles/README.md | |||||
#1 | 18810 | tjuricek |
First-pass at JavaScript client SDK. JavaScript requires Node with Gulp to "browserfy" the library. It's the easiest way I found to use the swagger-js project; bundle up a wrapping method. There is no JavaScript reference guide. The swagger-js doesn't really document what they do very well, actually. Overall I'm not particularly impressed by swagger-js, it was hard to even figure out what the right method syntax was. We may want to invest time in doing it better. This required setting CORS response headers, which are currently defaulted to a fairly insecure setting. |