method ISseService.peek
Since 0.4.0
ISseService.peek(name: string): SseChannel | undefined

Returns the named channel if one already exists, without creating it.

The non-allocating counterpart to ISseService.channel. A presence or dashboard endpoint that reports size for a name taken from a request must use this: channel(name) would register one channel per distinct name polled, and an SSE channel is never reclaimed before shutdown.

Examples

Example 1

const subscribers = sse.peek(`build:${id}`)?.size ?? 0;

Parameters

name: string

Channel name

Return Type

SseChannel | undefined

The channel, or undefined when no channel of that name exists

Usage

import { type ISseService } from "common/src/index.ts";