The celio library has this method defined in their store code:
onChange(key, handler) {
const keyChannel = `__keyspace@${this.database}__:${key}`
this.subscriber.subscribe(keyChannel)
this.subscriber.on('message', (channel, event) => {
if (channel === keyChannel) {
handler(event)
}
})
}
where this.subscriber is defined as:
this.client = redis.createClient(options)
this.subscriber = this.client.duplicate()