Skip to content

Commit

Permalink
But in a basic cache, and a few api methods to hack against
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-costello committed Jun 9, 2015
1 parent 94d30ef commit 4217ada
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/cache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var _cache = [];

function EventHandler(token, eventName, handler, enabled) {
this.elementToken = token;
this.eventName = 'click.namespacename';
this.eventType = 'click';
this.namespace = 'namespace';
this.handler = handler;
this.enabled = enabled;
}

module.exports = {
add : function(token, eventName, handler) {
_cache[token] = new EventHandler(token, eventName, handler, true);
},
removeHandler : function(token, handler) {
delete _cache[token];
},
getHandlers : function(token, eventName) {
return _cache
.filter(function(entry) {
return entry.elementToken === token && entry.eventName === eventName;
})
.map(function(h) {
return h.handler;
});
}
};
1 change: 1 addition & 0 deletions src/evt.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
var cache = require('cache');
var evtAttributeName = '__evt';
var idCount = 1;
var tree = {};
Expand Down

0 comments on commit 4217ada

Please sign in to comment.