-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Operator to support AJAX persistence and multicasting #2013
Comments
I love the I often use it to share data across components/routes when making HTTP requests that don't need to be refreshed often: https://github.com/sjtrimble/fluin.io/blob/master/src/app/shared/post.service.ts Or I used it to eliminate re-processing of incoming data from data streams. |
@StephenFluin it should be noted that |
What if we simplified it to always persist all values and multicast and we called it Observable.ajax.getJSON('http://something.com/whatever').shareResults(); Thoughts? |
I also think |
Use-case to consider (shared auto-updating value, which should not be updated in periods without subscribers): if (cache) { return cache; }
let serviceCall = Observable.ajax.getJSON('http://something.com/whatever')
.retryWhen(errors => errors.concatMap(() => Observable.timer(period)));
cache = serviceCall
.expand(() => Observable.timer(period).concatMap(() => serviceCall))
.cache(1, period);
return cache; |
@newsash I think we'll introduce a |
@Blesh |
+1 for |
Any update on when this might land? It's a highly desirable operator. |
Would it be possible to include a parameter that will control how many previous emissions are replayed? That would also satisfy @IgorMinar request. |
`shareReplay` returns an observable that is the source multicasted over a `ReplaySubject`. That replay subject is recycled on error from the `source`, but not on completion of the source. This makes `shareReplay` ideal for handling things like caching AJAX results, as it's retryable. It's repeat behavior, however, differs from `share` in that it will not repeat the `source` observable, rather it will repeat the `source` observable's values. related #2013, #453, #2043
This is |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Currently, there's a PR to remove
cache
#2012. The original intention ofcache
was to support use-cases, mostly coming from the Angular 2 community, revolving around wanting to persist successful AJAX requests, but still enableretry
andretryWhen
on failed AJAX requests.This operator should
Stuff to consider, and unanswered questions:
Observable.interval(100)
, for example)hot
observable?Possible Solutions
cache
operator but rename it to something more descriptive of it's purpose.shareResults
proposed hereFor sake of discussion, we'll call this operator
persist
.The text was updated successfully, but these errors were encountered: