WebSocketSubject

class WebSocketSubject<T> extends AnonymousSubject { constructor(urlConfigOrSource: string | WebSocketSubjectConfig<T> | Observable<T>, destination?: Observer<T>) _output: Subject<T> lift<R>(operator: Operator<T, R>): WebSocketSubject<R> multiplex(subMsg: () => any, unsubMsg: () => any, messageFilter: (value: T) => boolean) _subscribe(subscriber: Subscriber<T>): Subscription unsubscribe() }

Constructor

constructor(urlConfigOrSource: string | WebSocketSubjectConfig<T> | Observable<T>, destination?: Observer<T>)

Parameters

urlConfigOrSource

Type: string | WebSocketSubjectConfig | Observable.

destination

Optional. Default is undefined.

Type: Observer.

Properties

PropertyTypeDescription
_output

Methods

lift()

lift<R>(operator: Operator<T, R>): WebSocketSubject<R>

Parameters

operator

Type: Operator.

Returns

WebSocketSubject<R>

multiplex()

Creates an Observable, that when subscribed to, sends a message, defined by the subMsg function, to the server over the socket to begin a subscription to data over that socket. Once data arrives, the messageFilter argument will be used to select the appropriate data for the resulting Observable. When teardown occurs, either due to unsubscription, completion or error, a message defined by the unsubMsg argument will be send to the server over the WebSocketSubject.

multiplex(subMsg: () => any, unsubMsg: () => any, messageFilter: (value: T) => boolean)

Parameters

subMsg

A function to generate the subscription message to be sent to the server. This will still be processed by the serializer in the WebSocketSubject's config. (Which defaults to JSON serialization)

unsubMsg

A function to generate the unsubscription message to be sent to the server at teardown. This will still be processed by the serializer in the WebSocketSubject's config.

messageFilter

A predicate for selecting the appropriate messages from the server for the output stream.

_subscribe()

_subscribe(subscriber: Subscriber<T>): Subscription

Parameters

subscriber

Type: Subscriber.

Returns

Subscription

unsubscribe()

unsubscribe()

Parameters

There are no parameters.