Skip to content

Commit

Permalink
Revert "fix(first): unsubscription logic properly called on complete …
Browse files Browse the repository at this point in the history
…and error (#2463)"

This reverts commit af747f0.
  • Loading branch information
benlesh authored Jun 14, 2017
1 parent af747f0 commit 8d96532
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 55 deletions.
16 changes: 0 additions & 16 deletions spec/helpers/doNotUnsubscribe.ts

This file was deleted.

36 changes: 0 additions & 36 deletions spec/operators/first-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {expect} from 'chai';
import * as Rx from '../../dist/cjs/Rx';
import marbleTestingSignature = require('../helpers/marble-testing'); // tslint:disable-line:no-require-imports
import { doNotUnsubscribe } from '../helpers/doNotUnsubscribe';

declare const { asDiagram };
declare const hot: typeof marbleTestingSignature.hot;
Expand Down Expand Up @@ -221,41 +220,6 @@ describe('Observable.prototype.first', () => {
expectSubscriptions(e1.subscriptions).toBe(sub);
});

it('should unsubscribe from the source after first value, even if destination doesn\'t unsubscribe', () => {
const e1 = hot('--^---a---|');
const sub = '^---!';
const expected = '----(a|)';

const result = e1.first().let(doNotUnsubscribe);

expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(sub);
});

it('should unsubscribe from the source after completion without value,' +
' even if destination doesn\'t unsubscribe', () => {
const e1 = hot('--^---|');
const sub = '^---!';
const expected = '----(a|)';

const result = e1.first(undefined, undefined, 'a').let(doNotUnsubscribe);

expectObservable(result).toBe(expected);
expectSubscriptions(e1.subscriptions).toBe(sub);
});

it('should unsubscribe from the source after erroring without value,' +
' even if destination doesn\'t unsubscribe', () => {
const e1 = hot('--^---|');
const sub = '^---!';
const expected = '----#';

const result = e1.first().let(doNotUnsubscribe);

expectObservable(result).toBe(expected, undefined, new Rx.EmptyError());
expectSubscriptions(e1.subscriptions).toBe(sub);
});

it('should support type guards without breaking previous behavior', () => {
// tslint:disable no-unused-variable

Expand Down
3 changes: 0 additions & 3 deletions src/operator/first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@ class FirstSubscriber<T, R> extends Subscriber<T> {
this._emitted = true;
destination.next(value);
destination.complete();
this.unsubscribe();
this.hasCompleted = true;
}
}
Expand All @@ -166,10 +165,8 @@ class FirstSubscriber<T, R> extends Subscriber<T> {
if (!this.hasCompleted && typeof this.defaultValue !== 'undefined') {
destination.next(this.defaultValue);
destination.complete();
this.unsubscribe();
} else if (!this.hasCompleted) {
destination.error(new EmptyError);
this.unsubscribe();
}
}
}

0 comments on commit 8d96532

Please sign in to comment.