You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now I need a selector per single object in the object map. I have a lot of objects here and it is not possible to create selectors one by one. For this purpose I found 3 ways:
The solution which does not work and I do not understand why.
objectById(id: string): Observable {
return this.select(state => {
// method never enter this line
return state.objectMap[id]
})
}
objectById$ = this.objectById;
This solution works, but my reducer first needs to change the whole objectMap structure to fire objectMap selector first and after that change the reference/update value of my object. But changing the reference of the whole objectMap structure is not ok for me, I do not want that.
The third solution I did to test, just for one object. It works fine but I do not need it since I want a dynamic method for object subscription by id (as 1) or 2) above).
I am using Angular 12 and ngrx store 12.1.0. Whole question is described here:
https://stackoverflow.com/questions/69220483/ngrx-component-store-selector-by-parameter-does-not-always-fire
I will repeat the text:
I have an objects map structure that I keep in the component store:
I have selector:
and this works perfectly, fire every time I changed the structure of the whole map.
I also have an updater which change the value of a single object:
Now I need a selector per single object in the object map. I have a lot of objects here and it is not possible to create selectors one by one. For this purpose I found 3 ways:
objectById(id: string): Observable {
2 and 3 works, but I do not need them. I do not understand why solution 1 does not work?
The text was updated successfully, but these errors were encountered: