Replies: 2 comments 2 replies
-
Thanks for opening this RFC. TLDR; Dedicated Component Store is nice to have but not necessary. Initially, I think a dedicated Component Store solution would be nice to have for the following reasons:
But the CONS you've outlined in the RFC are all valid. The overlap between Component Store and Feature Store will be large and will cause a lot of confusion for the consumers which, to me, I think is even worse than NOT having a Component Store at all. That said, I'd still like to see a local-focused solution in terms of State Management from MiniRx. Maybe Feature Store can be reworked to be more local-focused? Several concerns come to mind:
PS: Should this be a Discussion rather than an Issue? |
Beta Was this translation helpful? Give feedback.
-
POCs: 1.) Grouped Feature StoresInstantiate many Feature Stores with the same key. The corresponding feature states are automatically grouped in the global state object: Usage:
PR: #70 2.) Many instances with unique featureKeyMany instances of the same Feature Store by automatically appending a unique ID to the featureKey Usage:
PR: #103 3.) InstantiationModes (SINGLE, MULTIPLE, MULTIPLE_DETACHED)
Usage:
PR: #105 4.) Simple StoreThe dedicated class for local state management: SimpleStore is almost the same like StateService from my blogpost "Simple yet powerful state management in Angular with RxJS" SimpleStore is also extended by FeatureStore. Usage:
PR: #107 5.) Component StoreFull-fledged Component Store for local state management. Feature Store and Component Store share almost the same API with a few exceptions... Component Store:
Feature Store extends Component Store. Having Component Store does not add much to the bundle-size. Usage:
PR: #153 Support for the Store extensions in Component Store is not foreseen. I doubt that the extensions are very useful in local state management. NgRx Component Store has proven it :) Will it be confusing to have Feature Store and Component Store in the same lib?If Component Store makes it into MiniRx then the docs section about it should be very thin. For most APIs the Component Store docs should refer to the APIs documented for Feature Store. Just the use-case and the differences with Feature Store should be described. I believe it is possible to add Component Store without to much confusion. |
Beta Was this translation helpful? Give feedback.
-
A Component Store could be beneficial to manage state at a local (component) level.
But let's see what we have already in MiniRx...
MiniRx Store and Feature Store manage state at a global level:
MiniRx Store
Read more in the MiniRx Store docs here: https://mini-rx.io/docs/redux
MiniRx Feature Stores
Read more in the MiniRx Feature Store docs here: https://mini-rx.io/docs/fs-quick-start
Feature Stores as Component Store
MiniRx Feature Stores come close to a Component Store since they are destroyable.
See an example in the Angular Demo here: https://angular-demo.mini-rx.io/#/counter
The "counter" Feature Store looks like this:
https://github.com/spierala/mini-rx-angular-demo/blob/main/src/app/modules/counter/state/counter-state.service.ts
Note that it has to provide a unique feature key:
The feature key is used to register the counter states into the global state object:
The counter component provides its own instance of the counter-state.service. See here:
https://github.com/spierala/mini-rx-angular-demo/blob/main/src/app/modules/counter/counter/counter.component.ts#L9
When the counter components are destroyed then the corresponding feature states are removed from the global state object.
Feature Stores as Component Store PROs & CONs
PROs
CONs
MiniRx Component Store?
What could it look like?
Mini Redux?
MiniRx Component Store PROs & CONs
PROs
CONs
Make the best of Feature Store?
Internal unique id creation?
We could try to make the registration of multiple Feature Stores more straightforward, especially the unique id thing, which could be handled internally
Detached Mode?
Prevent Feature Store from the registration on the global Redux store. Instead the Feature Store could fall back to a local Redux.
Again we need Redux mostly to keep the undo functionality (using the UndoExtension).
Non Goals
What do you think?
Beta Was this translation helpful? Give feedback.
All reactions