Skip to content

Commit

Permalink
fix(useWebSocket)!: rename type WebSocketOptions to `UseWebSocketOp…
Browse files Browse the repository at this point in the history
…tions` and `WebSocketResult` to `UseWebSocketReturn` (#1895)
  • Loading branch information
okxiaoliang4 committed Jul 13, 2022
1 parent 7155053 commit b461f3e
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/core/useWebSocket/index.ts
Expand Up @@ -6,7 +6,7 @@ import { useEventListener } from '../useEventListener'

export type WebSocketStatus = 'OPEN' | 'CONNECTING' | 'CLOSED'

export interface WebSocketOptions {
export interface UseWebSocketOptions {
onConnected?: (ws: WebSocket) => void
onDisconnected?: (ws: WebSocket, event: CloseEvent) => void
onError?: (ws: WebSocket, event: Event) => void
Expand Down Expand Up @@ -83,7 +83,7 @@ export interface WebSocketOptions {
protocols?: string[]
}

export interface WebSocketResult<T> {
export interface UseWebSocketReturn<T> {
/**
* Reference to the latest data received via the websocket,
* can be watched to respond to incoming messages
Expand Down Expand Up @@ -135,8 +135,8 @@ function resolveNestedOptions<T>(options: T | true): T {
*/
export function useWebSocket<Data = any>(
url: string,
options: WebSocketOptions = {},
): WebSocketResult<Data> {
options: UseWebSocketOptions = {},
): UseWebSocketReturn<Data> {
const {
onConnected,
onDisconnected,
Expand Down

0 comments on commit b461f3e

Please sign in to comment.