Skip to content

Commit

Permalink
feat(Subject): add rxSubscriber symbol
Browse files Browse the repository at this point in the history
  • Loading branch information
benlesh committed Dec 8, 2015
1 parent d4f1670 commit d2e4257
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions spec/subject-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
Expand Down
5 changes: 5 additions & 0 deletions src/Subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -20,6 +21,10 @@ export class Subject<T> extends Observable<T> implements Observer<T>, Subscripti
_subscriptions: Subscription<T>[];
_unsubscribe: () => void;

[rxSubscriber]() {
return this;
}

static create<T>(source: Observable<T>, destination: Observer<T>): Subject<T> {
return new BidirectionalSubject(source, destination);
}
Expand Down

0 comments on commit d2e4257

Please sign in to comment.