Conceptual Question NGRX Signal store - Many small features vs. few big features? #4545
-
Heyho, I've been experimenting with the ngrx signal store on a private project of mine. The approach I went with originally was making many tiny features ( So I'm wondering if maybe my approach was wrong and instead it makes more sense to have a larger Does this maybe go beyond just this usecase and was a general design-intention behind the signal-store? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
I can only give you my opinion but exceeding 16 indicates that your store is too large. If the same store is required in any component/service which is sending a request, that's the wrong approach. Split your store into multiple pieces. You will have some state which applies to only a component/component tree. That would be a component provided state, which you can also provide in root, if you want your state stays alive. For state which is used application-wide, go with root provided state. If your application heavily depends on eventing, you might also consider to use Redux, which means the extension of the toolkit or the global store. |
Beta Was this translation helpful? Give feedback.
I can only give you my opinion but exceeding 16 indicates that your store is too large. If the same store is required in any component/service which is sending a request, that's the wrong approach.
Split your store into multiple pieces. You will have some state which applies to only a component/component tree. That would be a component provided state, which you can also provide in root, if you want your state stays alive.
For state which is used application-wide, go with root provided state.
If your application heavily depends on eventing, you might also consider to use Redux, which means the extension of the toolkit or the global store.