@ngrx/store Ignore first emitted value

If you are not interested in the first emitted value, you should be able to use the skip operator:

store.select(...).skip(1)...

skip operators need piping now, you can use skip like this:

store.pipe(select(...), skip(1));

In terms of the 'hacky' part, it is a standard practice in ngrx to set an initial state with properties set to null. and that value gets emitted initially. so the first value you get will be null in these cases.

Alternatively you could also consider skipwhile(https://www.learnrxjs.io/learn-rxjs/operators/filtering/skipwhile) and use it like this:

store.pipe(select(...), skipWhile(val => val === undefined));

where undefined is the initial value of the property you are interested in. Rather than setting the initial value of the property to undefined, you could use null as the initial value as well, and change the above skipwhile() accordingly.

Tags:

Ngrx