Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var extend = require('xtend');
module.exports = SinkEventHandler;
function SinkEventHandler(sink, data) {
if (!(this instanceof SinkEventHandler)) {
return new SinkEventHandler(sink, data);
}
this.sink = sink;
this.id = sink.id;
this.data = extend({ preventDefault: true }, data);
}
SinkEventHandler.prototype.handleEvent = handleEvent;
function handleEvent(ev) {
var data = this.data;
if (data.preventDefault) ev.preventDefault();
if (typeof this.sink === 'function') {
this.sink(this.data);
} else {
this.sink.write(this.data);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.