https://github.com/alexeveritt/event-emitter
A simple javascript event emitter for use in the browser
https://github.com/alexeveritt/event-emitter
Last synced: 3 months ago
JSON representation
A simple javascript event emitter for use in the browser
- Host: GitHub
- URL: https://github.com/alexeveritt/event-emitter
- Owner: alexeveritt
- Created: 2016-01-29T00:41:02.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2016-09-25T10:16:31.000Z (over 8 years ago)
- Last Synced: 2025-01-02T11:44:25.997Z (5 months ago)
- Language: JavaScript
- Size: 3.91 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Javascript EventEmitter
A simple javascript event emitter for use in the browser written with commonJSI wrote this in about an hour to get a job done, so it's not fully tested at the moment and needs a bit of refactoring.
I will come back and clean up however I thought I'd share it in the meantime :)```
var EventEmitter = require('./event-emitter');
var emitter=new EventEmitter();
emitter.on('start', function(msg){alert(msg)};);
emitter.emit('start', 'started');
```Below is an example of how the EventEmitter can be inherited by another class
```
var EventEmitter = require('./event-emitter');
module.exports = car;
var self;function car() {
self = this;
EventEmitter.apply(this, arguments)}
car.prototype = Object.create(EventEmitter.prototype);
car.prototype.startCar = function() {
self.emit('starting', 'car go broom broom!');
};
```