Instance Method
subscribe(to:messageReceiver:onSubscribe:onUnsubscribe:)
Subscribes the client to the specified Redis channels, invoking the provided message receiver each time a message is published.
func subscribe(to channels: [RedisChannelName], messageReceiver receiver: @escaping RedisSubscriptionMessageReceiver, onSubscribe subscribeHandler: RedisSubscriptionChangeHandler?, onUnsubscribe unsubscribeHandler: RedisSubscriptionChangeHandler?) -> EventLoopFuture<Void>
Parameters
channelsThe names of channels to subscribe to.
receiverA closure which will be invoked each time a channel with a name in
channelspublishes a message.subscribeHandlerAn optional closure to be invoked when the subscription becomes active.
unsubscribeHandlerAn optional closure to be invoked when the subscription becomes inactive.
Return Value
A notification NIO.EventLoopFuture that resolves once the subscription has been registered with Redis.
Discussion
See SUBSCRIBE
Important
This will establish the client in a “PubSub mode” where only a specific list of commands are allowed to be executed.
Commands issued with this client outside of that list will resolve with failures.
See the PubSub specification