Skip to content

Instantly share code, notes, and snippets.

@jhusain
Created April 19, 2015 16:27
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhusain/4b14f5069f3a254cfa0a to your computer and use it in GitHub Desktop.
Save jhusain/4b14f5069f3a254cfa0a to your computer and use it in GitHub Desktop.
Converting event to Observable
function fromEvent(dom, eventName) {
return {
forEach: function(observer) {
var handler = (e) => {
observer.onNext(e);
};
dom.addEventListener(eventName, handler);
// Subscription
return {
dispose: function() {
dom.removeEventListener(eventName, handler);
}
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment