WebSocketSubject

class stable

class WebSocketSubject<T> extends AnonymousSubject {
  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

Type: string | WebSocketSubjectConfig | Observable.

destination

Optional. Default is undefined.

Type: Observer.

Methods

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

Deprecation Notes

Internal implementation detail, do not use directly. Will be made internal in v8.

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 sent 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.

unsubscribe()

Parameters

There are no parameters.

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