You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
370 B

  1. /**
  2. * Module exports.
  3. */
  4. module.exports = on;
  5. /**
  6. * Helper for subscriptions.
  7. *
  8. * @param {Object|EventEmitter} obj with `Emitter` mixin or `EventEmitter`
  9. * @param {String} event name
  10. * @param {Function} callback
  11. * @api public
  12. */
  13. function on(obj, ev, fn) {
  14. obj.on(ev, fn);
  15. return {
  16. destroy: function(){
  17. obj.removeListener(ev, fn);
  18. }
  19. };
  20. }