RedisClient.subscribe method | Bun module | Bun
BuildDocsReferenceGuidesBlogDiscord/
Bun/
RedisClient/
subscribeMsubscribe
Search the reference...
/
BuildDocsReferenceGuidesBlogDiscord/
Bun/
RedisClient/
subscribeMsubscribe
method
RedisClient.subscribesubscribe(channel: string,listener:
StringPubSubListener): Promisenumber>;
Subscribe to a Redis channel.
Subscribing disables automatic pipelining, so all commands will be received immediately.
Subscribing moves the channel to a dedicated subscription state which prevents most other commands from being executed until unsubscribed. Only .ping(), .subscribe(), and .unsubscribe() are legal to invoke in a subscribed upon channel.
@param channel
The channel to subscribe to.
@param listener
The listener to call when a message is received on the channel. The listener will receive the message as the first argument and the channel as the second argument.
await client.subscribe("my-channel", (message, channel) => {
console.log(`Received message on ${channel}: ${message}`);
});
subscribe(channels: string[],listener:
StringPubSubListener): Promisenumber>;
Subscribe to multiple Redis channels.
Subscribing disables automatic pipelining, so all commands will be received immediately.
Subscribing moves the channels to a dedicated subscription state in which only a limited set of commands can be executed.
@param channels
An array of channels to subscribe to.
@param listener
The listener to call when a message is received on any of the subscribed channels. The listener will receive the message as the first argument and the channel as the second argument.
Referenced typestype
StringPubSubListener = (message: string, channel: string) => void
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlog Toolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →