|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- import { Subject, AnonymousSubject } from '../../Subject';
- import { Subscriber } from '../../Subscriber';
- import { Observable } from '../../Observable';
- import { Subscription } from '../../Subscription';
- import { Operator } from '../../Operator';
- import { Observer, NextObserver } from '../../types';
-
- export interface WebSocketSubjectConfig<T> {
-
- url: string;
-
- protocol?: string | Array<string>;
-
- resultSelector?: (e: MessageEvent) => T;
-
-
- serializer?: (value: T) => WebSocketMessage;
-
-
- deserializer?: (e: MessageEvent) => T;
-
-
- openObserver?: NextObserver<Event>;
-
-
- closeObserver?: NextObserver<CloseEvent>;
-
-
- closingObserver?: NextObserver<void>;
-
-
- WebSocketCtor?: {
- new (url: string, protocols?: string | string[]): WebSocket;
- };
-
- binaryType?: 'blob' | 'arraybuffer';
- }
- export declare type WebSocketMessage = string | ArrayBuffer | Blob | ArrayBufferView;
- export declare class WebSocketSubject<T> extends AnonymousSubject<T> {
- private _config;
-
- _output: Subject<T>;
- private _socket;
- constructor(urlConfigOrSource: string | WebSocketSubjectConfig<T> | Observable<T>, destination?: Observer<T>);
- lift<R>(operator: Operator<T, R>): WebSocketSubject<R>;
- private _resetState;
- /**
- * Creates an {@link 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.
- *
- * @param 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)
- * @param 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.
- * @param messageFilter A predicate for selecting the appropriate messages
- * from the server for the output stream.
- */
- multiplex(subMsg: () => any, unsubMsg: () => any, messageFilter: (value: T) => boolean): Observable<any>;
- private _connectSocket;
- /** @deprecated This is an internal implementation detail, do not use. */
- _subscribe(subscriber: Subscriber<T>): Subscription;
- unsubscribe(): void;
- }
|