[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:
ybycode 2019-07-09 04:06:54 +02:00 committed by Armando Aguirre
parent b425235dce
commit affe9d13fc
2 changed files with 10 additions and 2 deletions

View File

@ -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 {

View File

@ -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();
}