ngxs / store

🚀 NGXS - State Management for Angular
http://ngxs.io
MIT License
3.54k stars 404 forks source link

📚[DOCS]: Recipes - Style Guide - Example Code #1592

Closed HansMusterWhatElse closed 2 years ago

HansMusterWhatElse commented 4 years ago

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:

Thanks in advance!

Best Regards Hans

bboydflo commented 4 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.

HansMusterWhatElse commented 4 years ago

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 {}