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.

createSocketRegistry

función

Crea un registro de clientes Socket tipados por canal, que se conectan al leer cada canal. Dentro de mountClientApp cada aplicación tiene su conexión por canal y la cierra al desmontarse; en un componente, la conexión pertenece a su raíz; fuera de ambos, el cliente es compartido y el llamador lo cierra. Es el autoimport socket de los clientes generados.

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

Source code src/app/runtime/socket.ts:441

Firma #

ts
function createSocketRegistry<C extends Record<string, SocketContract>>(contracts: C, options?: SocketRegistryOptions): SocketRegistry<C>

Type parameters #

C extends Record<string, SocketContract>

Parameters #

contracts C

Contratos públicos por nombre de canal.

options SocketRegistryOptions optional

Opciones comunes a todos los canales.

Returns #

SocketRegistry<C>

El registro tipado.

Example #

ts
import { createSocketRegistry } from "@meekojs/meeko/framework";
import { socketContracts } from "./socket-contracts.js";

export const socket = createSocketRegistry(socketContracts);
// En el navegador:
socket.chat.on("message", (message) => console.log(message.text));

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/runtime/socket.ts