-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
RxJS support #430
Comments
Related:
|
@stubailo @Urigo I think I did it. Take a look at this project https://github.com/kamilkisiela/apollo-rx-observable |
Of course we can move it under apollostack organisation as a separate package or even use it in |
|
Killer feature for |
ApolloClient + RxJS - proposal |
For more: |
@kamilkisiela @stubailo, what happened to this. is this part of apollo-client? I'm haveing trouble with rxjs forkJoin #1109 |
We didn't want to include it in |
so you'll keep to maintain to builds of apollo-client in future? Why you decided to keep it seperate? Wouldn't it make sense to include in the main library and extend base library. AOT building and three shaking should avoid bundle size increase, so I think it should not be a big issue, but threes and functionality stay in sync? |
The
First of all. Not everyone uses tree-shaking. A lot of people use just the browserify, if I would include RxJS related things inside the
As I said, those are two separate packages. The To sum it up. Maybe in the future they will decide to include RxJS inside |
@kamilkisiela Hi, is there a chance that apollo-client-rxjs will be added as a separate repo in the apollostack org? Great job on this by the way! Excited about trying it out in Angular |
@somombo But why? :) Maybe someday Thanks and enjoy |
@kamilkisiela Oh I just figured it might get a little better visibility for the community. |
Here's an implementation of
QueryObservable
that works with RxJS.To solve that problem I created a custom observable called
ApolloQueryObservable
that extendsObservable
from RxJS.QueryObservable
is saved underapollo
property. This way I could create methods likerefetch()
,startPolling()
,stopPolling()
. Every method usesApolloQueryObservable.apollo
to call specific method.As you can see, it still won't work with operators. Here's why.
Every operator uses
Observable.lift()
method, for examplemap()
.Observable.lift()
creates newObservable
, then assigns the current observable undersource
property. Here the moment where our custom methods (refetch etc) are being dropped.I solved this by overwriting
lift()
method.Now, the
lift()
method creates a new instance ofApolloQueryObservable
instead ofObservable
, and passes theQueryObservable
fromapollo
property in the constructor.Every operator returns now
ApolloQueryObservable
.Problem with
subscribe
methodAn example
It happens because there is no
_subscription
method inside the ApolloQueryObservable.Even if we add one, we still need to subscibe to the
QueryObservable
(this.apollo
).I solved this here.
So now we can subscribe to an Observable at any point.
I was thinking about moving this
ApolloQueryObservable
(in different name, whatever) toApolloClient
, because it's not angular2 specific and will help a lot of people, I think.The text was updated successfully, but these errors were encountered: