Skip to content

Commit

Permalink
Merge pull request #1998 from blesh/fix_bufferTime
Browse files Browse the repository at this point in the history
fix(bufferTime): no errors with take after bufferTime with maxBufferSize
  • Loading branch information
kwonoj authored Oct 4, 2016
2 parents d7355c7 + ecec640 commit 981c0ff
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
19 changes: 19 additions & 0 deletions spec/operators/bufferTime-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,4 +300,23 @@ describe('Observable.prototype.bufferTime', () => {
expectObservable(result).toBe(expected, values);
expectSubscriptions(e1.subscriptions).toBe(subs);
});

it('should not have errors when take follows and maxBufferSize is provided', () => {
const tick = 10;
const bufferTime = 50;
const expected = '-----a----b----c----d----(e|)';
const values = {
a: [0, 1, 2, 3],
b: [4, 5, 6, 7, 8],
c: [9, 10, 11, 12, 13],
d: [14, 15, 16, 17, 18],
e: [19, 20, 21, 22, 23]
};

const source = Rx.Observable.interval(tick, rxTestScheduler)
.bufferTime(bufferTime, null, 10, rxTestScheduler)
.take(5);

expectObservable(source).toBe(expected, values);
});
});
2 changes: 1 addition & 1 deletion src/operator/bufferTime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class BufferTimeSubscriber<T> extends Subscriber<T> {
closeAction.unsubscribe();
this.remove(closeAction);

if (this.timespanOnly) {
if (!this.closed && this.timespanOnly) {
context = this.openContext();
const bufferTimeSpan = this.bufferTimeSpan;
const timeSpanOnlyState = { subscriber: this, context, bufferTimeSpan };
Expand Down

0 comments on commit 981c0ff

Please sign in to comment.