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); }