Closed HansMusterWhatElse closed 2 years ago
@HansMusterWhatElse I am very new to Angular and been using ngxs for a couple of months so I don't have enough experience.
But regarding your question about substates I think it has something to do with how original redux works (combineReducers) where instead of declaring a big, more complicated state slice and reducer, a better approach is to declare small reducers and combine them in the end. it is more manageable. So I think the idea of substates may come from that original redux implementation.
I definitely get that but what would be the whole point of making something like the following injectable? Wouldn't that be pointless without the proper context? You can definitely sign me up for small states but for me they should have a reason to be independent.
Thanks anyways for your response! :)
@State<RowStateModel>({
name: 'row',
defaults: {
id: -1
}
})
@Injectable()
export class RowState {}
Description
Hi guys,
First of all - great job with the NGXS-framework and documentation. I really enjoyed reading through it in my free time.
Just recently I came across this part in the Style Guide documentation.
Regarding that example code I have a few questions:
Is there a particular reason that it's adviced to have tiny injectable sub states instead of something like an aggregate root which manages all substates for that particular concern?
Is there a particular need to have this sub state (e.g GridStateModel) inejctable? Is this needed in order to work with Angular in the first place?
Is this considered best-practise for NGXS?
Thanks in advance!
Best Regards Hans