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

Implement the futures Stream trait for subscriptions #10

Open
lulf opened this issue Mar 17, 2022 · 0 comments
Open

Implement the futures Stream trait for subscriptions #10

lulf opened this issue Mar 17, 2022 · 0 comments

Comments

@lulf
Copy link
Collaborator

lulf commented Mar 17, 2022

Instead of having a receive_message() method on the client, have the subscribe_* methods return a type holding a mut reference to the client, and implementing the Stream trait from the futures crate. Usage

let sub = client.subscribe_to_topic(...).await;

loop {
   if let Ok(message) = sub.next().await {
       // Process message
   }
}

Then when sub goes out of scope, the client can be reused.

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

No branches or pull requests

1 participant