Loading start and finish

PHOTO EMBED

Fri Jan 20 2023 05:06:51 GMT+0000 (Coordinated Universal Time)

Saved by @ilivanilton #angular #rxjs-pattern

  dataSource$ = this.dataSourceAction$.pipe(
    startWith([]),
    switchMap(() => {
      this.isLoadingResultsSubject.next(true);
      return this.getProduct(1).pipe(catchError(() => of(null)))
    }),
    map( data => {
      this.isLoadingResultsSubject.next(false);
      if(data === null) return []
      return data;
    }),);
content_copyCOPY