-
Notifications
You must be signed in to change notification settings - Fork 133
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
Implemented Generic AsyncIterator #78
Conversation
@alexleung , thank you! |
I figured that the existing unit tests for the asyncIterator method would suffice since the API for the AsyncIterator and PubSubEngine have not changed. |
Any chance we can get these changes integrated? |
If you guys ask me, we should also extract the core concept of a |
Is there any hope for this to get merged? |
Would like to use this in |
@alfaproject @jedwards1211 Yes, have hope! I in theory have the power to merge this! I'll try to take a look this week. Do note that I don't work for Apollo and that this does seem like a breaking change... Additionally, I have to coordinate with Apollo for releases; I don't have the ability to cut releases. |
I can take another look at this in a few days as well. |
Sorry I took a while to look at this. This mostly seems fine to me. There's some formatting change noise in the diff, and @NeoPhi's feedback should be pretty easy to address. Can you add notes to the README under vNEXT or whatever it's called? Also, a rebase or merge to fix the conflicts would be wonderful. My primary concern is that #143 is still around. @jedwards1211 can you weigh in with a summary of what we know so far? Does using AsyncIterators still cause memory leaks in combination with async generators? Additionally, I think it would make sense for the By the way, we should note that this shouldn't break existing implementations, due to how Typescript handles abstract classes (i.e. allows treating them as interfaces). https://stackoverflow.com/questions/35990538/extending-vs-implementing-a-pure-abstract-class-in-typescript |
I can rebase instead if it makes it easier to review. I noticed that a new test case was added which requires that no listeners be added until |
Sorry, mind fart - I meant the changelog.
But they already have to, right? So no existing code should break, they just wouldn't be using your implementation.
Seems like this was fixed in DefinitelyTyped/DefinitelyTyped#30856, I'll make a note to check whether a fix is released or not by the time we release this.
See #143 - the concern was that certain use patterns could cause listeners to leak. The listening boolean isn't part of the public interface... I'm not quite sure, honestly, what it was intended to mean. Do you have any use cases in mind re: a client wanting to run some logic before awaiting the next event? I'm personally having difficulty thinking of any where immediately calling |
You mean documenting the updates made here for the next release? I don't have access to release drafting. If I did I would summarize the change as: Replaced
This can work. My worry is just that the requirement to do this to achieve the behavior of an immediately subscribed AsyncIterator seems a little unintuitive, and should definitely be documented somewhere. This would be best addressed in a separate issue/PR. |
I updated the PubSub Implementations section of README so it's up-to-date with the changes made. |
I meant https://github.com/apollographql/graphql-subscriptions/blob/master/CHANGELOG.md Sorry, work is super busy again I will look at this again as soon as I have the time |
@grantwwu I'd love to see this get merged, do you mind taking a look at it again? |
😰 Every time I go to GitHub right now I feel a twinge of guilt at not keeping up with my commitments here... I'll try to make time. In the meantime, do you think you could fix the merge/rebase conflicts? |
@grantwwu sure! ah wait, I can't rebase and push commits to this; I could rebase and open a new PR if you want |
@jedwards1211 I sent you an invite to be a collaborator |
@alexleung thanks! |
@alexleung @grantwwu hey guys, I mainly use Flow, not TypeScript, but...won't changing |
In TypeScript, abstract classes can be implemented or extended. When a subclass implements an abstract class, it must implement all of the public methods of the abstract class, including those that the abstract class implements itself. If a subclass extends an abstract class, then it inherits any methods the abstract class implements. Therefore this is not a breaking change. |
@alexleung interesting, okay sounds good |
…ementations won't have to implement their own AsyncIterator.
…SubEngine is now an abstract class with an opt-in default AsyncIterator implementation. Also removed a couple of trailing white spaces.
@grantwwu @alexleung okay, I rebased and very carefully merged in the logic to not subscribe until the first call to next() |
Sorry for the extended delay... |
Do either of you (@alexleung or @jedwards1211) mind if I merge a version that I've fixed up myself? |
I don't mind |
I don't mind either. |
Merged as #198 |
The AsyncIterator takes in a PubSubEngine. I also changed the PubSubEngine from an interface to an abstract class, with all methods being abstract except for the asyncIterator method which is implemented. The advantage of this contribution is that now all different types of Apollo PubSubEngines can share the same AsyncIterator code instead of each having to implement their own version. @davidyaha has brought this contribution into his graphql-redis-subscriptions repository so far, but we both think it would be best to merge the contribution here instead.