Skip to main content
zerotal

Documentation


Documentation / @zerotal/broadcasting / ChannelRegistry

Class: ChannelRegistry

Defined in: broadcasting/src/ChannelRegistry.ts:67

Constructors

Constructor

new ChannelRegistry(): ChannelRegistry

Returns

ChannelRegistry

Methods

register()

register(pattern, callback): void

Defined in: broadcasting/src/ChannelRegistry.ts:76

Register an authorization callback for a channel pattern.

Parameters

pattern

string

callback

ChannelCallback

Returns

void

Example

registry.register("orders.[orderId]", (user, orderId) => user.id === ownerOf(orderId));

all()

all(): object[]

Defined in: broadcasting/src/ChannelRegistry.ts:82

Registered channel patterns (for channel:list / introspection).

Returns

object[]


clear()

clear(): void

Defined in: broadcasting/src/ChannelRegistry.ts:87

Remove all registrations (test isolation).

Returns

void


authorize()

authorize(channelName, user): Promise<AuthorizeResult>

Defined in: broadcasting/src/ChannelRegistry.ts:98

Authorize a subscription. The channel name may carry a private-/presence- prefix; it is stripped before matching (patterns are registered without the prefix).

Returns { matched: false } when no pattern claims the channel (caller should deny), or { matched: true, result } where result is the callback's return value.

Parameters

channelName

string

user

unknown

Returns

Promise<AuthorizeResult>