A versatile and robust event emitter class.
Features
- Versatile API that's flexible and consistent
- Cross-emitter listening, allowing for easier management of many listeners
- Regular expression listeners
- Asynchronous Listeners with
emitAsync()
- Listener modifiers; a fluent interface for modifying listeners
- Set callbacks and contexts with
calling()
andusing()
- Migration via
moveTo()
,addTo()
, andremoveFrom()
- Remove listeners from all emitters with
off()
- Limit occurrences with
occur()
pause()
,resume()
, andisPaused()
- Create evented
race()
andall()
promises - Duplication with
clone()
- Set callbacks and contexts with
- Browser environment compatible
- Competitive and consistent performance
- Rx compatible with
toObservable()
- Helpers like
stopPropagation()
andlistenerCount
extend()
any object- Global and per-instance
config()
options - Over 200 tests with 100% code coverage
- Written in TypeScript
Example
; { this; } let Normandy = ;let Tempest = ; // Add two listeners via a listener maplet listeners = Normandy; // Attach the same listeners to Tempest that are on Normandylisteners; // Launch Tempest when Normandy launchesTempest ; // Launch both ships to the Andromeda GalaxyNormandy; // Stop listening to both shipslisteners;
Installation
Node.js via Yarn
yarn add event-station
Node.js via npm
npm install event-station --save
SystemJS via jspm
jspm install npm:event-station
Web browser via Bower
bower install event-station
Web browser via <script>
Downloads
Latest Release
- ES5 Build
- Compatible with AMD and CommonJS module loaders
- Assigns an
EventStation
global when not imported as a module
- ES6 Build
- For use with an ES6 module loader
- jsnext Build
- ES5 compatible objects as an ES module. See the Rollup Wiki for details.
- ES5 Minified Build
- ES5 Build minified with UglifyJS 2
- Source Map
- The source map for the minified build
- Definition
- Generated TypeScript definition
Documentation
- Usage documentation
- This guide will explain the general usage of Event-Station.
- Module definition
- The associated definition file can be used as an API reference.
License
Copyright © 2016 Morris Allison III.
Released under the MIT license.
References
Event-Station was influenced by EventEmitter2 and Backbone.Events.