W3cubDocs

/RxJS

WebSocketSubject

class stable

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

Property Type Description
_output Subject<T>

Methods

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

Parameters

operator

Type: Operator.

Returns

WebSocketSubject<R>

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

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.

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(subscriber: Subscriber<T>): Subscription

Parameters

subscriber

Type: Subscriber.

Returns

Subscription

unsubscribe()

Parameters

There are no parameters.

© 2015–2018 Google, Inc., Netflix, Inc., Microsoft Corp. and contributors.
Code licensed under an Apache-2.0 License. Documentation licensed under CC BY 4.0.
https://rxjs.dev/api/webSocket/WebSocketSubject