[**Documentation**](../../../README)

***

[Documentation](../../../README) / [@zerotal/notifications](../README) / BroadcastMessage

# Class: BroadcastMessage

Defined in: [notifications/src/BroadcastMessage.ts:10](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/BroadcastMessage.ts#L10)

The broadcastable representation of a notification, returned from `Notification.toBroadcast()`.
Wraps the data payload plus optional queue routing.

## Example

```ts
toBroadcast() {
  return new BroadcastMessage({ invoiceId: this.invoice.id, amount: this.invoice.amount });
}
```

## Constructors

### Constructor

> **new BroadcastMessage**(`data`): `BroadcastMessage`

Defined in: [notifications/src/BroadcastMessage.ts:14](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/BroadcastMessage.ts#L14)

#### Parameters

##### data

`Record`\<`string`, `unknown`\>

#### Returns

`BroadcastMessage`

## Properties

### queue

> **queue**: `string` \| `undefined` = `undefined`

Defined in: [notifications/src/BroadcastMessage.ts:12](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/BroadcastMessage.ts#L12)

Queue to deliver this broadcast on. Unset means deliver inline.

***

### data

> `readonly` **data**: `Record`\<`string`, `unknown`\>

Defined in: [notifications/src/BroadcastMessage.ts:14](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/BroadcastMessage.ts#L14)

## Methods

### onQueue()

> **onQueue**(`queue`): `this`

Defined in: [notifications/src/BroadcastMessage.ts:28](https://github.com/zerotaldev/zerotal/blob/1d6fb26b05b18ba077de1bfaeb46c42131cd8b70/packages/notifications/src/BroadcastMessage.ts#L28)

Deliver this broadcast from a queue rather than inline.

Worth doing when the broadcast fans out to many connections and the
request should not wait for it. The trade is latency: a queued broadcast
arrives whenever a worker picks it up.

#### Parameters

##### queue

`string`

#### Returns

`this`

#### Example

```ts
toBroadcast() {
  return new BroadcastMessage({ id: this.report.id }).onQueue("broadcasts");
}
```
