diff --git a/spec/observables/dom/webSocket-spec.ts b/spec/observables/dom/webSocket-spec.ts index 15efd84afa..72ca69f53b 100644 --- a/spec/observables/dom/webSocket-spec.ts +++ b/spec/observables/dom/webSocket-spec.ts @@ -52,6 +52,29 @@ describe('Observable.webSocket', () => { subject.unsubscribe(); }); + it('should allow the user to chain operators', () => { + let messageReceived = false; + const subject = Observable.webSocket('ws://mysocket'); + + subject + .map(x => x + '?') + .map(x => x + '!') + .map(x => x + '!') + .subscribe((x: string) => { + expect(x).to.equal('pong?!!'); + messageReceived = true; + }); + + const socket = MockWebSocket.lastSocket; + + socket.open(); + + socket.triggerMessage(JSON.stringify('pong')); + expect(messageReceived).to.be.true; + + subject.unsubscribe(); + }); + it('receive multiple messages', () => { const expected = ['what', 'do', 'you', 'do', 'with', 'a', 'drunken', 'sailor?']; const results = []; diff --git a/src/observable/dom/WebSocketSubject.ts b/src/observable/dom/WebSocketSubject.ts index 8e85586faa..293b5b4681 100644 --- a/src/observable/dom/WebSocketSubject.ts +++ b/src/observable/dom/WebSocketSubject.ts @@ -1,7 +1,6 @@ import {Subject, AnonymousSubject} from '../../Subject'; import {Subscriber} from '../../Subscriber'; import {Observable} from '../../Observable'; -import {Operator} from '../../Operator'; import {Subscription} from '../../Subscription'; import {root} from '../../util/root'; import {ReplaySubject} from '../../ReplaySubject'; @@ -68,12 +67,6 @@ export class WebSocketSubject extends AnonymousSubject { this.destination = new ReplaySubject(); } - lift(operator: Operator) { - const sock: WebSocketSubject = new WebSocketSubject(this, this.destination); - sock.operator = operator; - return sock; - } - // TODO: factor this out to be a proper Operator/Subscriber implementation and eliminate closures multiplex(subMsg: () => any, unsubMsg: () => any, messageFilter: (value: T) => boolean) { const self = this;