apollographql / apollo-feature-requests

🧑‍🚀 Apollo Client Feature Requests | (no 🐛 please).
Other
130 stars 7 forks source link

Use Async Generators instead of zen-observable #94

Open crubier opened 5 years ago

crubier commented 5 years ago

Apollo link makes heavy use of zen-observable.

However ES2018 features async generators, aka async iterators, and it seems to me that they are a replacement for Observables, with less object-orientation smell.

Since Async generators are now a standard feature of javascript (and python, and C#, and others...), I believe apollo should be using those.

I understand that it would probably need breaking changes (or maybe it wouldn't ?), but I believe it would make sense in the longer term.

crubier commented 5 years ago

See https://github.com/apollographql/apollo-link/issues/774

benjamn commented 5 years ago

This is definitely something we are considering for Apollo Client 3.0! Not only does the Observable implementation require more code than async iterables, but the sometimes-sync/sometimes-async behavior of observables also leads to brittle code that sometimes requires await but not always.

benjamn commented 5 years ago

Also, as a somewhat indirect argument in favor of async iterables, I would encourage anyone to try writing a function that converts an Observable to an async iterator, and then a function that does the opposite. One of those directions is much easier than the other!

crubier commented 5 years ago

Just saw the 2.6 release blog post mentions this, should we close ?

https://blog.apollographql.com/whats-new-in-apollo-client-2-6-b3acf28ecad1