publish

View as Markdown

publish

  • publish(params): Promise<void>

Publish a message into the specified channel.

Parameters

NameTypeDescription
paramsObject-
params.channelstringChannel in which to send the message.
params.contentanyThe message to send. This can be any JSON-serializable object.
params.meta?Record<any, any>Metadata associated with the message. There are no requirements on the content of metadata.

Returns

Promise<void>

Examples

Publishing a message as a string:

1await pubSubClient.publish({
2 channel: "my-channel",
3 content: "Hello, world.",
4});

Publishing a message as an object:

1await pubSubClient.publish({
2 channel: "my-channel",
3 content: {
4 field_one: "value_one",
5 field_two: "value_two",
6 },
7});