UI for Zipcoin Blue

WebSocketSubject.d.ts 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import { AnonymousSubject } from '../../Subject';
  2. import { Subscriber } from '../../Subscriber';
  3. import { Observable } from '../../Observable';
  4. import { Subscription } from '../../Subscription';
  5. import { Operator } from '../../Operator';
  6. import { Observer, NextObserver } from '../../Observer';
  7. export interface WebSocketSubjectConfig {
  8. url: string;
  9. protocol?: string | Array<string>;
  10. resultSelector?: <T>(e: MessageEvent) => T;
  11. openObserver?: NextObserver<Event>;
  12. closeObserver?: NextObserver<CloseEvent>;
  13. closingObserver?: NextObserver<void>;
  14. WebSocketCtor?: {
  15. new (url: string, protocol?: string | Array<string>): WebSocket;
  16. };
  17. binaryType?: 'blob' | 'arraybuffer';
  18. }
  19. /**
  20. * We need this JSDoc comment for affecting ESDoc.
  21. * @extends {Ignored}
  22. * @hide true
  23. */
  24. export declare class WebSocketSubject<T> extends AnonymousSubject<T> {
  25. url: string;
  26. protocol: string | Array<string>;
  27. socket: WebSocket;
  28. openObserver: NextObserver<Event>;
  29. closeObserver: NextObserver<CloseEvent>;
  30. closingObserver: NextObserver<void>;
  31. WebSocketCtor: {
  32. new (url: string, protocol?: string | Array<string>): WebSocket;
  33. };
  34. binaryType?: 'blob' | 'arraybuffer';
  35. private _output;
  36. resultSelector(e: MessageEvent): any;
  37. /**
  38. * Wrapper around the w3c-compatible WebSocket object provided by the browser.
  39. *
  40. * @example <caption>Wraps browser WebSocket</caption>
  41. *
  42. * let socket$ = Observable.webSocket('ws://localhost:8081');
  43. *
  44. * socket$.subscribe(
  45. * (msg) => console.log('message received: ' + msg),
  46. * (err) => console.log(err),
  47. * () => console.log('complete')
  48. * );
  49. *
  50. * socket$.next(JSON.stringify({ op: 'hello' }));
  51. *
  52. * @example <caption>Wraps WebSocket from nodejs-websocket (using node.js)</caption>
  53. *
  54. * import { w3cwebsocket } from 'websocket';
  55. *
  56. * let socket$ = Observable.webSocket({
  57. * url: 'ws://localhost:8081',
  58. * WebSocketCtor: w3cwebsocket
  59. * });
  60. *
  61. * socket$.subscribe(
  62. * (msg) => console.log('message received: ' + msg),
  63. * (err) => console.log(err),
  64. * () => console.log('complete')
  65. * );
  66. *
  67. * socket$.next(JSON.stringify({ op: 'hello' }));
  68. *
  69. * @param {string | WebSocketSubjectConfig} urlConfigOrSource the source of the websocket as an url or a structure defining the websocket object
  70. * @return {WebSocketSubject}
  71. * @static true
  72. * @name webSocket
  73. * @owner Observable
  74. */
  75. static create<T>(urlConfigOrSource: string | WebSocketSubjectConfig): WebSocketSubject<T>;
  76. constructor(urlConfigOrSource: string | WebSocketSubjectConfig | Observable<T>, destination?: Observer<T>);
  77. lift<R>(operator: Operator<T, R>): WebSocketSubject<R>;
  78. private _resetState();
  79. multiplex(subMsg: () => any, unsubMsg: () => any, messageFilter: (value: T) => boolean): Observable<any>;
  80. private _connectSocket();
  81. /** @deprecated internal use only */ _subscribe(subscriber: Subscriber<T>): Subscription;
  82. unsubscribe(): void;
  83. }