Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeScript types #10

Open
AkisArou opened this issue Jul 12, 2022 · 1 comment
Open

TypeScript types #10

AkisArou opened this issue Jul 12, 2022 · 1 comment

Comments

@AkisArou
Copy link

Hello, I will use your lib in a project of mine, and I've implemented some typings.
Maybe you can add them if you'd like to!

declare module "robust-websocket" {
  declare class RobustWebSocket {
    constructor(streamUri: string | ((ws: WebSocket) => string), protocols: string[], options?: {
      timeout?: number;
      shouldReconnect?: (event: CloseEvent, ws: WebSocket) => number | boolean;
      automaticOpen?: boolean;
      ignoreConnectivityEvents?: boolean;
    });

    attempts: number;
    reconnects: number;
    readyState: number;
    url: string;
    protocol: string;
    extensions: string;
    bufferedAmount: number;
    binaryType: BinaryType;

    send(data: string | ArrayBufferLike | Blob | ArrayBufferView): void;

    close(code?: number, reason?: string): void;

    dispatchEvent(event: Event): boolean;


    addEventListener(type: "open", callback: (event: Event) => void): void;
    addEventListener(type: "close", callback: (event: CloseEvent) => void): void;
    addEventListener(type: "error", callback: (event: Event) => void): void;
    addEventListener(type: "message", callback: (event: MessageEvent) => void): void;

    removeEventListener(type: "open", callback: (event: Event) => void): void;
    removeEventListener(type: "close", callback: (event: CloseEvent) => void): void;
    removeEventListener(type: "error", callback: (event: Event) => void): void;
    removeEventListener(type: "message", callback: (event: MessageEvent) => void): void;
  }
}
@nathanboktae
Copy link
Owner

I'm more than happy to take a pull request for it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants