Ir al contenido
Español

EventChannel

Esta página aún no está disponible en tu idioma.

EventChannel<TEvent> = EventClass<TEvent> | EventKey<TEvent> | KindOf<TEvent>

Defined in: src/EventKey.ts:101

Anything that names an EventStream channel: a class whose instances are the events, a key naming their kind, or the bare kind string.

It is EventChannel, not the XReference the other key modules use, because “channel” is already the word the stream’s API and its JSDoc use for this parameter — and because there is no eventKeyOf to write: a class channel names no kind, so the three forms do not all reduce to a key the way every ShardReference reduces to a ShardKey.

The bare string is the shorthand, and it costs the type. TEvent has nothing to be inferred from and falls back to unknown, so a predicate written against it sees unknown — unless the caller supplies the argument (subscribe<UserLoggedInEvent>(ref, 'user-logged-in')), which is also what makes the string itself checkable. Prefer the key.

TEvent = unknown