import { DaffBestSellersEffects } from '@daffodil/product/state'
Effects for handling best seller actions and best seller service requests.
@Injectable()
class DaffBestSellersEffects<<T extends DaffProduct>> {
loadBestSellers$: Observable<any> = createEffect(() => this.actions$.pipe(
ofType(DaffBestSellersActionTypes.BestSellersLoadAction),
switchMap((action: DaffBestSellersLoad) =>
this.driver.getBestSellers()
.pipe(
map((resp) => new DaffBestSellersLoadSuccess(resp)),
catchError((error: DaffError) => of(new DaffBestSellersLoadFailure(this.errorMatcher(error)))),
),
),
))
}
Observable<any>
Default | createEffect(() => this.actions$.pipe(
ofType(DaffBestSellersActionTypes.BestSellersLoadAction),
switchMap((action: DaffBestSellersLoad) =>
this.driver.getBestSellers()
.pipe(
map((resp) => new DaffBestSellersLoadSuccess(resp)),
catchError((error: DaffError) => of(new DaffBestSellersLoadFailure(this.errorMatcher(error)))),
),
),
)) |
---|---|
Description | Handles BestSellersLoadAction by making a service call for best selling products and returning a success or failure action to the action stream. |