Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for subscribing to multiple channels #28

Merged
merged 2 commits into from
Dec 29, 2021

Conversation

ThomasTJdev
Copy link
Contributor

Currently we can only subscribe to a single channel with the subscribe(). This PR allows the user to subscribe to multiple channels - just like https://redis.io/commands/subscribe.

import redis, asyncdispatch

var isSub: bool
var c: AsyncRedis

proc dd() {.async.} =

  while true:
    if not isSub:
      c = await openAsync()
      await c.subscribe(@["files", "users"])
      isSub = true

    let data = await c.nextMessage()
    echo $data

when isMainModule:
  asyncCheck dd()
  runForever()
$ redis-cli
#Received
publish files newFile
#Not received
publish ula bla
#Received
publish users John

@dom96 dom96 merged commit ef30e75 into nim-lang:master Dec 29, 2021
ThomasTJdev added a commit to ThomasTJdev/redis that referenced this pull request Dec 30, 2021
ThomasTJdev added a commit to ThomasTJdev/redis that referenced this pull request Dec 30, 2021
dom96 pushed a commit that referenced this pull request Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants