Skip to content
Meeko
Type to search the guides and the API reference. Open it from any page with / or Ctrl K; move with the arrow keys and open a result with Enter.
Get started

Contents

On this page

Not translated yet

This page has not been translated into English yet, so it is shown in Spanish.

useSocket

constante Deprecated

Deprecated.

Desde 1.1.0: use useSocketClient. Se retirará en 2.0.

Alias obsoleto de useSocketClient: es la misma función, con la misma firma y los mismos tipos. No es el autoimport useSocket(canal, opciones) de las aplicaciones, que generan los clientes con useSocketChannel y no está obsoleto.

ts
import { useSocket } from "@meekojs/meeko/framework";

Source code src/app/composables/use-socket-client.ts:68

Firma #

ts
const useSocket: <C extends SocketContract>(url: string, contract: C, options?: SocketClientOptions) => SocketClient<C>

Type parameters #

C extends SocketContract

Parameters #

url string

URL ws: o wss: del canal.

contract C

Contrato del canal.

options SocketClientOptions optional

Opciones del cliente; sin onError, usa el observador de errores más cercano.

Returns #

SocketClient<C>

El cliente tipado; en SSR, uno inerte.

Example #

ts
// Antes:
import { useSocket } from "@meekojs/meeko/framework";
const chat = useSocket("wss://example.com/_meeko/socket/chat", chatContract);

// Ahora:
import { useSocketClient } from "@meekojs/meeko/framework";
const chat = useSocketClient("wss://example.com/_meeko/socket/chat", chatContract);

See also #

Was this page helpful?

Add a comment

It is sent when you choose “Yes” or “No”. Only the page, your answer and the comment are stored: no cookies and no personal data.

0 of 2000 characters

Edit on GitHub: packages/meeko/src/app/composables/use-socket-client.ts