GitHub

DaffProductRoutingCollectionEffects

import { DaffProductRoutingCollectionEffects } from '@daffodil/product/routing'

An abstract class that provides an effect for modifying the browser URL.

abstract class DaffProductRoutingCollectionEffects {
  update$: createEffect(() => this.actions$.pipe(ofType(...this.actionTypes), withLatestFrom(this.facade.metadata$), map(([action, metadata]): [Action, DaffCollectionRequest] => [
      action,
      {
          filterRequests: daffFiltersToRequests(metadata.filters),
          appliedSortOption: metadata.appliedSortOption,
          appliedSortDirection: metadata.appliedSortDirection,
          currentPage: metadata.currentPage,
          pageSize: metadata.pageSize
      },
  ]), tap(([action, request]) => this.router.navigate([], {
      relativeTo: this.route,
      queryParams: this.getQueryParams.getQueryParams(request),
      queryParamsHandling: 'merge'
  })), switchMap(() => EMPTY)), { dispatch: false }) = createEffect(() => this.actions$.pipe(
      ofType(...this.actionTypes),
      withLatestFrom(this.facade.metadata$),
      map(([action, metadata]): [Action, DaffCollectionRequest] => [
        action,
        {
          filterRequests: daffFiltersToRequests(metadata.filters),
          appliedSortOption: metadata.appliedSortOption,
          appliedSortDirection: metadata.appliedSortDirection,
          currentPage: metadata.currentPage,
          pageSize: metadata.pageSize,
        },
      ]),
      tap(([action, request]) => this.router.navigate(
        [],
        {
          relativeTo: this.route,
          queryParams: this.getQueryParams.getQueryParams(request),
          queryParamsHandling: 'merge',
        },
      )),
      switchMap(() => EMPTY),
    ), { dispatch: false })
}