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

Revert "fix(first): force unsubscription logic on complete and error" #2665

Merged
merged 1 commit into from
Jun 14, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
}
}
}