import { DaffProductEffects } from '@daffodil/product/state'
Effects for handling product actions and for triggering corresponding service requests.
@Injectable()
class DaffProductEffects<<T extends DaffProduct>> {
load$: Observable<any> = createEffect(() => this.actions$.pipe(
ofType(DaffProductActionTypes.ProductLoadAction),
switchMap((action: DaffProductLoad) =>
this.driver.get(action.payload)
.pipe(
map((resp) => new DaffProductLoadSuccess(resp)),
catchError((error: DaffError) => of(new DaffProductLoadFailure(this.errorMatcher(error)))),
),
),
))
}
Observable<any>
Default | createEffect(() => this.actions$.pipe(
ofType(DaffProductActionTypes.ProductLoadAction),
switchMap((action: DaffProductLoad) =>
this.driver.get(action.payload)
.pipe(
map((resp) => new DaffProductLoadSuccess(resp)),
catchError((error: DaffError) => of(new DaffProductLoadFailure(this.errorMatcher(error)))),
),
),
)) |
---|---|
Description | Handles ProductLoadAction by making a service call for a product and returning a success or failure action to the action stream. |