Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
231 views
in Technique[技术] by (71.8m points)

ngrx - immutability of objects causing multiple selectors to trigger changes

I am experimenting using NGRX, however I cannot understand how to set selectors to only trigger updates when the relevant data has changed.

I am using a normalized store to keep track of a list of conversations. Each conversation has some details and a list of message ids. I then also have the list of messages in my store. Eventually I want to be able to show my list of conversation details in one component, and another component will take care of showing the actual messages.

However the selector which gives me the conversation details is being triggered even when I add a message - this will cause this component to refresh its data even though nothing has changed.

I have created a skeleton of my structure on Stackblitz to explain better what's happening.

Can someone please indicate what I'm doing wrong? It seems as though the immutability part of NGRX is causing a lot of overhead for me.

Thanks.

question from:https://stackoverflow.com/questions/66068399/ngrx-immutability-of-objects-causing-multiple-selectors-to-trigger-changes

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...