Skip to content

Commit 44dfa07

Browse files
committed
fix(Subject): align parameter order to match with RxJS4
closes #1285 BREAKING CHANGE: Subject.create arguments have been swapped to match Rx 4 signature. `Subject.create(observable, observer)` is now `Subject.create(observer, observable)`
1 parent 2878aed commit 44dfa07

File tree

3 files changed

+8
-12
lines changed

3 files changed

+8
-12
lines changed

spec/Subject-spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ describe('Subject', function () {
411411
}
412412
};
413413

414-
var sub = Subject.create(source, destination);
414+
var sub = Subject.create(destination, source);
415415

416416
sub.subscribe(function (x) {
417417
output.push(x);
@@ -456,7 +456,7 @@ describe('Subject', function () {
456456
}
457457
};
458458

459-
var sub = Subject.create(source, destination);
459+
var sub = Subject.create(destination, source);
460460

461461
sub.subscribe(function (x) {
462462
output.push(x);
@@ -571,7 +571,7 @@ describe('Subject', function () {
571571
it('should not eager', function () {
572572
var subscribed = false;
573573

574-
var subject = new Rx.Subject(new Rx.Observable(function (observer) {
574+
var subject = new Rx.Subject(null, new Rx.Observable(function (observer) {
575575
subscribed = true;
576576
var subscription = Rx.Observable.of('x').subscribe(observer);
577577
return function () {

src/Subject.ts

+4-8
Original file line numberDiff line numberDiff line change
@@ -8,29 +8,25 @@ import {rxSubscriber} from './symbol/rxSubscriber';
88

99
export class Subject<T> extends Observable<T> implements Observer<T>, Subscription {
1010

11-
static create: Function = <T>(source: Observable<T>, destination: Observer<T>): Subject<T> => {
12-
return new Subject<T>(source, destination);
11+
static create: Function = <T>(destination: Observer<T>, source: Observable<T>): Subject<T> => {
12+
return new Subject<T>(destination, source);
1313
};
1414

15-
constructor(source?: Observable<T>, destination?: Observer<T>) {
15+
constructor(protected destination?: Observer<T>, protected source?: Observable<T>) {
1616
super();
17-
this.source = source;
18-
this.destination = destination;
1917
}
2018

2119
public observers: Observer<T>[] = [];
2220
public isUnsubscribed: boolean = false;
2321

24-
protected destination: Observer<T>;
25-
2622
protected isStopped: boolean = false;
2723
protected hasErrored: boolean = false;
2824
protected errorValue: any;
2925
protected dispatching: boolean = false;
3026
protected hasCompleted: boolean = false;
3127

3228
lift<T, R>(operator: Operator<T, R>): Observable<T> {
33-
const subject = new Subject(this, this.destination || this);
29+
const subject = new Subject(this.destination || this, this);
3430
subject.operator = operator;
3531
return <any>subject;
3632
}

src/observable/dom/WebSocketSubject.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export class WebSocketSubject<T> extends Subject<T> {
3939

4040
constructor(urlConfigOrSource: string | WebSocketSubjectConfig | Observable<T>, destination?: Observer<T>) {
4141
if (urlConfigOrSource instanceof Observable) {
42-
super(urlConfigOrSource, destination);
42+
super(destination, urlConfigOrSource);
4343
} else {
4444
super();
4545
this.WebSocketCtor = root.WebSocket;

0 commit comments

Comments
 (0)