Skip to content

Commit

Permalink
refactor events .on
Browse files Browse the repository at this point in the history
  • Loading branch information
kbrsh committed Apr 7, 2017
1 parent fb037ae commit a1121a2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions dist/moon.js
Original file line number Diff line number Diff line change
Expand Up @@ -1556,13 +1556,14 @@
/**
* Attaches an Event Listener
* @param {String} eventName
* @param {Function} action
* @param {Function} handler
*/
Moon.prototype.on = function (eventName, action) {
if (this.$events[eventName]) {
this.$events[eventName].push(action);
Moon.prototype.on = function (eventName, handler) {
var handlers = this.$events[eventName];
if (handlers !== undefined) {
handlers.push(handler);
} else {
this.$events[eventName] = [action];
this.$events[eventName] = [handler];
}
};

Expand Down
Loading

0 comments on commit a1121a2

Please sign in to comment.