method WorkersBroker.prototype.subscribe
WorkersBroker.prototype.subscribe<T>(
topic: string,
handler: MessageHandler<T>,
options?: SubscribeOptions
): Promise<ISubscription>

Subscribes to a topic.

Registration only: delivery happens when the Worker's queue export dispatches a batch into WorkersBroker.dispatch.

Type Parameters

The payload type

Parameters

topic: string

Source topic

handler: MessageHandler<T>

Invoked per delivered message

optional
options: SubscribeOptions

queue load-balances across members of one group

Return Type

Promise<ISubscription>

The active subscription

Usage

import { WorkersBroker } from "cloudflare-plugin/src/index.ts";