Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/wocket/mod.ts>WebSocketClient#on

A WebSocket library for Deno
Latest
method WebSocketClient.prototype.on
import { WebSocketClient } from "https://deno.land/x/wocket@v1.0.0/mod.ts";

Register a listener for a channel name

Examples

Example 1

on<{ name: string }>("user", message => {
  console.log(message.user.name);
})

Type Parameters

T extends Record<string, unknown>

Parameters

channelName: string
  • The channel name to listen on
cb: (message: T) => void
  • The handler