-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit f2b651b
Showing
3 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<script src='browser-events.js'></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
var BrowserEmitter = function () { | ||
var emitter = { | ||
events: [] | ||
}; | ||
|
||
emitter.on = (function (event, callback) { | ||
if (!(this.events[event] instanceof Array)) { | ||
this.events[event] = []; | ||
} | ||
return this.events[event].push(callback) - 1; | ||
}).bind(emitter); | ||
|
||
emitter.emit = (function (event) { | ||
var callbacks = this.events[event]; | ||
if (callbacks) { | ||
callbacks.forEach(function (callback) { | ||
if (callback instanceof Function) { | ||
callback(); | ||
} | ||
}); | ||
} | ||
}).bind(emitter); | ||
|
||
return emitter; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"name": "browser-events", | ||
"description": "Event emitters in the browser", | ||
"homepage": "https://github.com/jorgezaccaro/browser-events", | ||
"author": { | ||
"name": "Jorge Zaccaro", | ||
"email": "jorgezaccaro@gmail.com", | ||
"url": "https://github.com/jorgezaccaro" | ||
}, | ||
"version": "0.0.1", | ||
"license": "MIT", | ||
"depedencies": {}, | ||
"keywords": ["browser", "events", "emitters"], | ||
"main": "browser-events.js" | ||
} |