Pavel Gurecki
Jan 14 · 1 min read

It doesn’t make sense that selector would be executed just once in this case.
We can simplify example and remove “id” property:

this.counter2 = this.store.pipe(
select(fromRoot.getCount(), { multiply: 2 })
);
this.counter4 = this.store.pipe(
select(fromRoot.getCount(), { multiply: 4 })
);

For every count change, selector function _must_ run twice to compute count for every `multiply` value. If it would run once, how it would know result for e.g. multiply: 4 ?

That’s not possible, regardless of ngrx version.

More interesting example would be if we’d had same props value:

this.counter2 = this.store.pipe(
select(fromRoot.getCount(), { multiply: 2 })
);
this.counter4 = this.store.pipe(
select(fromRoot.getCount(), { multiply: 2 })
);

There’s no point in executing selector twice, as result of computation will be same for both instances.

How ngrx will handle this?

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade