angular2 rxjs observable forkjoin

kabus

Is it possible to continue forkjoin http.get requests even if one of the requests fails.

I'm looking to a similar function of $q.allSettled in angular2.

See example : http://jsfiddle.net/Zenuka/pHEf9/

angular.module('qAllSettled', []).config(function($provide) {
  $provide.decorator('$q', function($delegate) {
    var $q = $delegate;
    $q.allSettled = function(promises) {
      return $q.all(promises.map(function(promise) {
        return promise.then(function(value) {
          return { state: 'fulfilled', value: value };
        }, function(reason) {
          return { state: 'rejected', reason: reason };
        });
      }));
    };
    return $q;
  });
});

Kab

Thierry Templier

You could leverage the catch operator for each observable to intercept the error and return another observable in such cases.

Here is a sample:

return Observable.forkJoin(
  this.http.get('/some-url')
         .map((res:Response) => res.json())
         .catch(res:Response => Observable.of({}),
  this.http.get('/some-other-url')
         .map((res:Response) => res.json())
         .catch(res:Response => Observable.of({}),
);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Rxjs: Observable.combineLatest vs Observable.forkJoin

property 'forkJoin' does not exist on type 'typeof observable' - angular2

Angular2 rxjs missing observable.interval method

RxJS Angular2 handling 404 in Observable.forkjoin

Angular2 Observable.forkJoin of observable variables - ReferenceError: Observable is not defined

angular2 rxjs way to check forkJoin completely done

Rxjs filter operator not working with Angular2 Observable

Angular2 RxJs: simple take() from http returned observable

Angular 2 rxjs observables created from BehaviorSubject are not working with forkJoin

How to check if a RxJS Observable contains a string in Angular2?

How to Observable.interval multiple http requests (forkjoin) in rxjs

Angular2 rxjs sort (observable) list of objects by an observable field

Creating my own observable with rxjs and angular2

Observable.forkJoin of Angular Route Params Observable

Rxjs Observable Interval and Angular2 HTTP: wait for response

RxJS Observable merge angular

Error rxjs_Observable__.Observable.forkJoin is not a function?

Casting results from Observable.forkJoin to their respective types in Angular 2

Angular/RxJS: synchronous observable

Angular 5 - Rxjs forkJoin

RXJS forkJoin also takes Observable<[]>?

RxJs Observable forkJoin

Angular / RxJS Multicasting Observable of Observable

Angular RXJS forkJoin completion progress

rxjs forkJoin nested observable inside another observable

How to unsubscribe or dispose an interval observable on condition in Angular2 or RxJS?

Angular 7 RXjs 6.x - How to use forkJoin (difference between `of` and `Observable.create`)

RXJS/Angular Replace Observable

Angular/RxJS: forkjoin with more than 6 parameters