Functions
demultiplexDataPublisher
demultiplexDataPublisher<
TDataPublisher
,TChannelName
>(publisher
,sourceChannelName
,messageTransformer
):DataPublisher
Given a channel that carries messages for multiple subscribers on a single channel name, this function returns a new DataPublisher that splits them into multiple channel names.
Type Parameters
Type Parameter |
---|
TDataPublisher extends DataPublisher <Record <string , unknown >> |
TChannelName extends string |
Parameters
Parameter | Type | Description |
---|---|---|
publisher | TDataPublisher | - |
sourceChannelName | TChannelName | - |
messageTransformer | (message ) => void | [string , unknown ] | A function that receives the message as the first argument, and returns a tuple of the derived channel name and the message. |
Returns
Example
Imagine a channel that carries multiple notifications whose destination is contained within the message itself.
Now you can subscribe to only the messages you are interested in, without having to subscribe
to the entire 'message'
channel and filter out the messages that are not for you.