mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2025-10-16 12:05:41 +00:00
[phoenix] Fix SocketConnectOptions for phoenix >= 1.4.3 (#36715)
Adds/fixes types of SocketConnectOptions attributes: - Adds the missing attribute `binaryType`, - Adds the missing attribute `rejoinAfterMs`, - Fixes the type of `reconnectAfterMs`.
This commit is contained in:
parent
b425235dce
commit
affe9d13fc
5
types/phoenix/index.d.ts
vendored
5
types/phoenix/index.d.ts
vendored
@ -36,18 +36,21 @@ export class Channel {
|
||||
push(event: string, payload: object, timeout?: number): Push;
|
||||
}
|
||||
|
||||
export type BinaryType = 'arraybuffer' | 'blob';
|
||||
export type ConnectionState = 'connecting' | 'open' | 'closing' | 'closed';
|
||||
|
||||
export interface SocketConnectOption {
|
||||
binaryType: BinaryType;
|
||||
params: object | (() => object);
|
||||
transport: string;
|
||||
timeout: number;
|
||||
heartbeatIntervalMs: number;
|
||||
reconnectAfterMs: number;
|
||||
longpollerTimeout: number;
|
||||
encode: (payload: object, callback: (encoded: any) => void) => void;
|
||||
decode: (payload: string, callback: (decoded: any) => void) => void;
|
||||
logger: (kind: string, message: string, data: any) => void;
|
||||
reconnectAfterMs: (tries: number) => number;
|
||||
rejoinAfterMs: (tries: number) => number;
|
||||
}
|
||||
|
||||
export class Socket {
|
||||
|
||||
@ -1,7 +1,12 @@
|
||||
import { Socket, Channel, Presence } from 'phoenix';
|
||||
|
||||
function test_socket() {
|
||||
const socket = new Socket('/ws', {params: {userToken: '123'}});
|
||||
const socket = new Socket('/ws', {
|
||||
binaryType: 'arraybuffer',
|
||||
params: { userToken: '123' },
|
||||
reconnectAfterMs: tries => 1000,
|
||||
rejoinAfterMs: tries => 1000,
|
||||
});
|
||||
socket.connect();
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user