publish

View as Markdown

publish

  • publish(params): Promise<void>

Publish a message into the specified channel.

Parameters

params
objectRequired

Configuration object for publishing a message

params.channel
stringRequired

Channel in which to send the message.

params.content
anyRequired

The 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 pubSub.publish({
2 channel: "my-channel",
3 content: "Hello, world."
4});

Publishing a message as an object:

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