-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add a "SubscribeAsync()" method to the IRealtimeChannel interface #1287
Comments
Hi @danr-stadion, Thank you for reporting this issue. Implementing this feature is not straightforward, and we are currently discussing the implementation details internally, as well as deliberating whether we should proceed with it. Additionally, we aim to maintain a consistent public API across all SDKs, necessitating careful consideration of implementation details for other languages as well. In the meantime, you can address this use case by doing something like the following: var subject = new SequentialSimpleAsyncSubject<Message>();
await subject.Synchronize().SubscribeAsync(async message =>
{
Console.WriteLine($"DoSomeWorkAsync BEGIN for '{message.Id}'");
await Task.Delay(5000);
Console.WriteLine($"DoSomeWorkAsync END for '{message.Id}'");
});
channel.Subscribe(message => subject.OnNextAsync(message)); If you have any difficulties in implementing the workaround, please do not hesitate to reach out to us. We are more than willing to provide assistance. |
Hi @ttypic , I tried to implement your workaround but it looks like it depends on an "alpha" Nuget package: https://www.nuget.org/packages/System.Reactive.Async Unfortunately I'm not comfortable using alpha code in production, so I will just stick with my workaround using task factories. Thanks, |
@danr-stadion, initially, we didn't add an async version to discourage people from doing a lot of extra work in the subscribe actions as the next one can't be called until the current one has finished to ensure the correct order of messages. I know there are workarounds, but probably the best option is to use something like a blocking queue or the If you are using it as part of asp.net you can spin up a |
Hi,
Would it be possible to add a
SubscribeAsync()
method to theIRealtimeChannel
interface? It's currently impossible to make a call toasync
code in the message handler.Want to be able to do something like this:
The
Subscribe
method only acceptsAction<Message>
so you can't pass in a delegate which can be awaited.Thanks,
Dan.
┆Issue is synchronized with this Jira Task by Unito
The text was updated successfully, but these errors were encountered: