Skip to content

Commit

Permalink
chore: reduce throttle time for products effects
Browse files Browse the repository at this point in the history
  • Loading branch information
dhhyi committed Jul 14, 2020
1 parent 4500e8a commit 39b4091
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/app/core/store/shopping/products/products.effects.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { isPlatformBrowser } from '@angular/common';
import { Inject, Injectable, PLATFORM_ID } from '@angular/core';
import { Router } from '@angular/router';
import { Actions, createEffect, ofType } from '@ngrx/effects';
import { Dictionary } from '@ngrx/entity';
import { Store, select } from '@ngrx/store';
Expand Down Expand Up @@ -63,7 +64,8 @@ export class ProductsEffects {
private productsService: ProductsService,
private httpStatusCodeService: HttpStatusCodeService,
private productListingMapper: ProductListingMapper,
@Inject(PLATFORM_ID) private platformId: string
@Inject(PLATFORM_ID) private platformId: string,
private router: Router
) {}

loadProduct$ = createEffect(() =>
Expand Down Expand Up @@ -337,5 +339,7 @@ export class ProductsEffects {
)
);

private throttleOnBrowser = () => (isPlatformBrowser(this.platformId) ? throttleTime(3000) : map(identity));
private throttleOnBrowser() {
return isPlatformBrowser(this.platformId) && this.router.navigated ? throttleTime(100) : map(identity);
}
}

0 comments on commit 39b4091

Please sign in to comment.