diff --git a/spec/helpers/doNotUnsubscribe.ts b/spec/helpers/doNotUnsubscribe.ts deleted file mode 100644 index 29341119a6..0000000000 --- a/spec/helpers/doNotUnsubscribe.ts +++ /dev/null @@ -1,16 +0,0 @@ -/// -import * as Rx from '../../dist/cjs/Rx'; - -export function doNotUnsubscribe(ob: Rx.Observable): Rx.Observable { - return ob.lift(new DoNotUnsubscribeOperator()); -} - -class DoNotUnsubscribeOperator implements Rx.Operator { - call(subscriber: Rx.Subscriber, source: any): any { - return source.subscribe(new DoNotUnsubscribeSubscriber(subscriber)); - } -} - -class DoNotUnsubscribeSubscriber extends Rx.Subscriber { - unsubscribe() {} // tslint:disable-line no-empty -} diff --git a/spec/operators/first-spec.ts b/spec/operators/first-spec.ts index 395d7ca322..91f031dfbb 100644 --- a/spec/operators/first-spec.ts +++ b/spec/operators/first-spec.ts @@ -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; @@ -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 diff --git a/src/operator/first.ts b/src/operator/first.ts index 77180fb5e7..cb6d09baf4 100644 --- a/src/operator/first.ts +++ b/src/operator/first.ts @@ -156,7 +156,6 @@ class FirstSubscriber extends Subscriber { this._emitted = true; destination.next(value); destination.complete(); - this.unsubscribe(); this.hasCompleted = true; } } @@ -166,10 +165,8 @@ class FirstSubscriber extends Subscriber { 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(); } } }