Skip to content

Commit

Permalink
fix(Subject): align parameter order to match with RxJS4
Browse files Browse the repository at this point in the history
closes ReactiveX#1285

BREAKING CHANGE: Subject.create arguments have been swapped to match Rx
4 signature. `Subject.create(observable, observer)` is now
`Subject.create(observer, observable)`
  • Loading branch information
kwonoj committed Feb 5, 2016
1 parent 96fc860 commit 1121050
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
6 changes: 3 additions & 3 deletions spec/Subject-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ describe('Subject', function () {
}
};

var sub = Subject.create(source, destination);
var sub = Subject.create(destination, source);

sub.subscribe(function (x) {
output.push(x);
Expand Down Expand Up @@ -456,7 +456,7 @@ describe('Subject', function () {
}
};

var sub = Subject.create(source, destination);
var sub = Subject.create(destination, source);

sub.subscribe(function (x) {
output.push(x);
Expand Down Expand Up @@ -571,7 +571,7 @@ describe('Subject', function () {
it('should not eager', function () {
var subscribed = false;

var subject = new Rx.Subject(new Rx.Observable(function (observer) {
var subject = new Rx.Subject(null, new Rx.Observable(function (observer) {
subscribed = true;
var subscription = Rx.Observable.of('x').subscribe(observer);
return function () {
Expand Down
12 changes: 4 additions & 8 deletions src/Subject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,25 @@ import {rxSubscriber} from './symbol/rxSubscriber';

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

static create: Function = <T>(source: Observable<T>, destination: Observer<T>): Subject<T> => {
return new Subject<T>(source, destination);
static create: Function = <T>(destination: Observer<T>, source: Observable<T>): Subject<T> => {
return new Subject<T>(destination, source);
};

constructor(source?: Observable<T>, destination?: Observer<T>) {
constructor(protected destination?: Observer<T>, protected source?: Observable<T>) {
super();
this.source = source;
this.destination = destination;
}

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

protected destination: Observer<T>;

protected isStopped: boolean = false;
protected hasErrored: boolean = false;
protected errorValue: any;
protected dispatching: boolean = false;
protected hasCompleted: boolean = false;

lift<T, R>(operator: Operator<T, R>): Observable<T> {
const subject = new Subject(this, this.destination || this);
const subject = new Subject(this.destination || this, this);
subject.operator = operator;
return <any>subject;
}
Expand Down
2 changes: 1 addition & 1 deletion src/observable/dom/WebSocketSubject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export class WebSocketSubject<T> extends Subject<T> {

constructor(urlConfigOrSource: string | WebSocketSubjectConfig | Observable<T>, destination?: Observer<T>) {
if (urlConfigOrSource instanceof Observable) {
super(urlConfigOrSource, destination);
super(destination, urlConfigOrSource);
} else {
super();
this.WebSocketCtor = root.WebSocket;
Expand Down

0 comments on commit 1121050

Please sign in to comment.