From d2e425722b03d69d4797e0083c756eeed2323a7e Mon Sep 17 00:00:00 2001 From: Ben Lesh Date: Mon, 7 Dec 2015 11:02:35 -0800 Subject: [PATCH] feat(Subject): add rxSubscriber symbol --- spec/subject-spec.js | 5 +++++ src/Subject.ts | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/spec/subject-spec.js b/spec/subject-spec.js index de6adbf86b..0da12b2ac4 100644 --- a/spec/subject-spec.js +++ b/spec/subject-spec.js @@ -19,6 +19,11 @@ describe('Subject', function () { subject.complete(); }); + it('should have the rxSubscriber Symbol', function () { + var subject = new Subject(); + expect(subject[Rx.Symbol.rxSubscriber]()).toBe(subject); + }); + it('should pump values to multiple subscribers', function (done) { var subject = new Subject(); var expected = ['foo', 'bar']; diff --git a/src/Subject.ts b/src/Subject.ts index 07d8fd6640..da84bb05e1 100644 --- a/src/Subject.ts +++ b/src/Subject.ts @@ -4,6 +4,7 @@ import {Observable} from './Observable'; import {Subscriber} from './Subscriber'; import {Subscription} from './Subscription'; import {SubjectSubscription} from './subject/SubjectSubscription'; +import {rxSubscriber} from './symbol/rxSubscriber'; const subscriptionAdd = Subscription.prototype.add; const subscriptionRemove = Subscription.prototype.remove; @@ -20,6 +21,10 @@ export class Subject extends Observable implements Observer, Subscripti _subscriptions: Subscription[]; _unsubscribe: () => void; + [rxSubscriber]() { + return this; + } + static create(source: Observable, destination: Observer): Subject { return new BidirectionalSubject(source, destination); }