Skip to content

Commit

Permalink
Ensure join disposes outer stream
Browse files Browse the repository at this point in the history
  • Loading branch information
briancavalier committed Oct 2, 2014
1 parent 8bd133e commit 96bfd02
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/combinators/join.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ function handleStep(i, index, s) {

function stepOuter(i, s) {
if(i.done) {
return s.length === 1 ? i : stepJoin(replace(endOuter(s[0].stream), 0, s));
return s.length === 1 ? i : stepJoin(replace(endOuter(i, s[0].stream), 0, s));
}

return stepJoin(append(stepPair(i.value), stepAtIndex(i, 0, s)));
Expand Down Expand Up @@ -73,8 +73,8 @@ function stepPair(stream) {
return { stream: stream, i: when(stream.step, stream.state) };
}

function endOuter(stream) {
return { stream: stream, i: neverP };
function endOuter(i, stream) {
return { stream: stream, i: disposeOuter(i, stream) };
}

function getIteration(s) {
Expand All @@ -90,6 +90,12 @@ function without(step, index, arr) {
}, stream.dispose(step.time, step.value, step.state));
}

function disposeOuter (i, stream) {
return when(function () {
return neverP;
}, stream.dispose(i.time, i.value, i.state));
}

function disposeInners(t, x, s) {
return all(map(function(si) {
return si.stream.dispose(t, x, si.i);
Expand Down

0 comments on commit 96bfd02

Please sign in to comment.