Skip to content

Commit

Permalink
docs(component-store): prevent emitting changes on initialization in …
Browse files Browse the repository at this point in the history
…MatPaginator example (#3164)

Closes #2921
  • Loading branch information
boradakash authored Oct 6, 2021
1 parent 605fd02 commit a03666b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injectable } from '@angular/core';
import { ComponentStore } from '@ngrx/component-store';
import { filter, tap, map, withLatestFrom, pairwise } from 'rxjs/operators';
import { filter, tap, map, withLatestFrom, pairwise, skip } from 'rxjs/operators';
import { Observable } from 'rxjs';

export interface PaginatorState {
Expand Down Expand Up @@ -145,6 +145,9 @@ export class PaginatorStore extends ComponentStore<PaginatorState> {
}),
// debounce, so that we let the state "settle"
{ debounce: true }
).pipe(
// Skip the emission of the initial state values
skip(1)
);
// #enddocregion selectors

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ViewEncapsulation,
} from '@angular/core';
import { ComponentStore } from '@ngrx/component-store';
import { filter, tap, withLatestFrom, map, pairwise } from 'rxjs/operators';
import { filter, tap, withLatestFrom, map, pairwise, skip } from 'rxjs/operators';

export interface PaginatorState {
/** The current page index. */
Expand Down Expand Up @@ -92,6 +92,9 @@ export class PaginatorComponent {
}),
// debounce, so that we let the state "settle" before emitting a value
{ debounce: true }
).pipe(
// Skip the emission of the initial state values
skip(1)
);

// *********** Updaters *********** //
Expand Down

0 comments on commit a03666b

Please sign in to comment.