rxjs / 7.5.5 / api / websocket / websocketsubject.html /

WebSocketSubject

class stable

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

Constructor

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

Parameters

urlConfigOrSource string | WebSocketSubjectConfig<T> | Observable<T>
destination Observer<T>

Optional. Default is undefined.

Methods

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

Parameters

operator Operator<T, R>

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 finalization occurs, either due to unsubscription, completion, or error, a message defined by the unsubMsg argument will be sent to the server over the WebSocketSubject.

Parameters

subMsg () => any

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 () => any

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

messageFilter (value: T) => boolean

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

unsubscribe()

Parameters

There are no parameters.

© 2015–2022 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