Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating a stream from an EventEmitter should remove listener on destruction #500

Closed
jgrund opened this issue Jun 17, 2016 · 1 comment
Closed
Labels

Comments

@jgrund
Copy link
Collaborator

jgrund commented Jun 17, 2016

Consider:

const ee = new EventEmitter();
const s = highland('someEvent', ee);

typeof ee._events.someEvent; // function

s.destroy();

typeof ee._events.someEvent; // function

Given that highland adds a new listener to ee on creation it should also remove that listener on destruction.

We should be able to use _destructors to register the removal:

  function eeHandler () {
    var ctx = mapper.apply(this, arguments);
    self.write(ctx);
  }

  ee.on(xs, eeHandler);

  var removeMethod = ee['removeListener'] || ee['unbind'];

  if (removeMethod)
     this._destructors.push(function () {
       ee[removeMethod](xs, eeHandler);
    });
@vqvu
Copy link
Collaborator

vqvu commented Mar 23, 2017

Closing since it's been fixed. Fix should be live in 2.10.5 or 3.0.0-beta.4.

@vqvu vqvu closed this as completed Mar 23, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants