Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Subject): align parameter order to match with RxJS4 #1305

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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