caolan / highland

High-level streams library for Node.js and the browser
https://caolan.github.io/highland
Apache License 2.0
3.43k stars 146 forks source link

Otherwise doesn't forward 'end' event #142

Open brian-gates opened 9 years ago

brian-gates commented 9 years ago

In the below snippet, I expect both the generator and otherwise 'end' events to fire, but only the generator's ever does.

var generator = $(function (push, next) {
  push(null, $.nil);
});

generator.on('end', function () {
  console.log('generator end');
})

var otherwise = $([]).otherwise(generator).on('end', function() {
  console.log('otherwise end')
});
generator.resume();
otherwise.resume();
apaleslimghost commented 9 years ago

Sounds a bit like #104.

vqvu commented 9 years ago

One note, this is a bug, but not in the way that you have specified.

The proper test case shouldn't have generator.resume() in it, since calling resume on a stream with no consumers will completely drain it, which leaves nothing to redirect to in otherwise.