-
-
Notifications
You must be signed in to change notification settings - Fork 10
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
Question about EventSequence #19
Comments
This wasn't the intentional behavior. What do you think should happen here? And, do you know why adding a delay helped? If you are talking about multiple consumers of |
In my case, adding the delay mostly worked because then I would only start listening to the stream once, so I wouldn't have the issue. You're right that it isn't possible at the moment to broadcast the events. I guess it could be done by using another method, however this isn't a huge issue so I don't think it's needed |
The behavior isn't good, but it's more about how AsyncSequence works than this library. If you do not agree, please re-open! |
The problem is eventSequence is an instance var of a class but it should be a computed var so it can be created by multiple clients, since that is the how they are designed to work. E.g. you can create a streams for NotificationCenter notifications all over your app and filter or process each one how you like, you aren't limited to one notification stream. I noticed the CoreLocation team has made the same design flaw in their CLMonitor events stream. |
Ok, I'm listening! If |
Continuations are for bridging between delegates/closures to async. Since you say your design already is async perhaps you could have a collection of Then you might also like to wrap each I'll give this design a try tomorrow to see if it fixes the issue with |
Here is an implementation that did choose to use a collection of continuations: |
I've looked into this and learned the best way to implement multiple consumers of the eventSequence is for the client to hold an array of One place:
Many places:
Since |
Thanks for all your investigations and input here. I do appreciate it! |
Hi,
I was refactoring some of my code and stumbled upon a weird issue: I couldn't get events from
eventSequence
(inRestartingServer
) anymore. When I added a delay, it works fine. Turns out, it was because I accidentally started the task containing thefor await _ in eventSequence
twice, and cancelled the first one. Cancelling a task will cancel the streams inside it too, therefore cancellingeventSequence
. A cancelled stream cannot be restarted, removing the ability to get any more events from the language server, as I cannot find a way to make a newEventSequence
with the public API.I was wondering if this falls under "intended behavior"? Could it be beneficial to have the ability to create multiple
EventSequence
instances, so a sequence can be cancelled and multiple tasks can get the events?The text was updated successfully, but these errors were encountered: