GitHub

DaffProductGridEffects

import { DaffProductGridEffects } from '@daffodil/product/state'

Effects for handling product grid actions and for triggering corresponding service requests.

@Injectable()
class DaffProductGridEffects<<T extends DaffProduct>>  {
  loadAll$: Observable<any> = createEffect(() => this.actions$.pipe(
      ofType(DaffProductGridActionTypes.ProductGridLoadAction),
      switchMap((action: DaffProductGridLoad) =>
        this.driver.getAll()
          .pipe(
            map((resp) => new DaffProductGridLoadSuccess(resp)),
            catchError((error: DaffError) => of(new DaffProductGridLoadFailure(this.errorMatcher(error)))),
          ),
      ),
    ))
}

Properties

loadAll$
Observable<any>
DefaultcreateEffect(() => this.actions$.pipe( ofType(DaffProductGridActionTypes.ProductGridLoadAction), switchMap((action: DaffProductGridLoad) => this.driver.getAll() .pipe( map((resp) => new DaffProductGridLoadSuccess(resp)), catchError((error: DaffError) => of(new DaffProductGridLoadFailure(this.errorMatcher(error)))), ), ), ))
Description

Handles ProductGridLoadAction by making a service call for products and returning a success or failure action to the action stream.