getChannel
Call Signature
Section titled “Call Signature”getChannel<
TMap>(name):Channel<TMap>
Defined in: packages/postal/src/channel.ts:745
Gets or creates a singleton channel by name.
The first call with a given name creates the channel. Subsequent calls return the same instance. The type map generic is compile-time only — all call sites referencing the same channel name should use the same map.
Two ways to type a channel:
-
Explicit type map — pass
TMapdirectly: -
Registry augmentation — declare once, infer everywhere:
Type Parameters
Section titled “Type Parameters”TMap extends Record<string, unknown>
Parameters
Section titled “Parameters”string
The channel name (defaults to "__default__")
Returns
Section titled “Returns”Channel<TMap>
The singleton channel instance
Call Signature
Section titled “Call Signature”getChannel<
TName>(name?):Channel<ResolveChannelMap<TName>>
Defined in: packages/postal/src/channel.ts:746
Gets or creates a singleton channel by name.
The first call with a given name creates the channel. Subsequent calls return the same instance. The type map generic is compile-time only — all call sites referencing the same channel name should use the same map.
Two ways to type a channel:
-
Explicit type map — pass
TMapdirectly: -
Registry augmentation — declare once, infer everywhere:
Type Parameters
Section titled “Type Parameters”TName extends string = "__default__"
Parameters
Section titled “Parameters”TName
The channel name (defaults to "__default__")
Returns
Section titled “Returns”Channel<ResolveChannelMap<TName>>
The singleton channel instance