Replies: 2 comments 7 replies
-
Hi @Harpush, This is the expected behavior of the readonly isDataFilled$ = this.select(
this.hasData$,
this.data$,
(hasData, data) => { /* projector */ },
{ debounce: true }
); I will convert this bug report to a discussion because the reported default behavior of the |
Beta Was this translation helpful? Give feedback.
-
@alex-okrushko I ended up doing this:
My question is: Is that an applicable solution? Are there any pitfalls I can't see right now? I will gladly hear your opinion. observeOn(asapSceduler),
concatMap(value => forkJoin([of(value), this.someSelector$.pipe(first())])) |
Beta Was this translation helpful? Give feedback.
-
Minimal reproduction of the bug/regression with instructions
https://stackblitz.com/edit/ngrx-seed-xboxzw?file=src/app/store.service.ts
Open console and see the logs
Minimal reproduction of the bug/regression with instructions
Due to
combineLatest
usage inside component store select each dependent selector emission invokes recalculation. That means even a single update to the reducer can cause multiple selector recalculations with wrong and unexpected data too.Only using debounce can solve it - but the regular effect problems arise.
The example above creates three selectors:
I would expect on
data
update that each selector runs once. What actually happens without debounce isisDataFilled$
runs twice for each dependent selector change. Even worse the data will be partial (hasData as true and data as undefined).The real problem is say with 5 dependent selectors a single update that affects the result of all the 5 selectors will trigger the combined selector 5 times. In regular NGRX store it doesn't work this way but the way I expect.
This kind of bugs are really hard to find and I can't see a good fix for it...
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
NgRx: 13
Angular: 13
Other information
It seems that debounce cannot be avoided... I believe the only way to solve it is debounce always and custom rxjs operator for async select debounced selectors. The only other option is maybe tweaking
combineLatest
usage... not sure its possible.I would be willing to submit a PR to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions