your opinions on a state management system
See original GitHub issueWhich @angular/* package(s) are relevant/releated to the feature request?
No response
Description
I find ngrx (redux) too heavy and complicated (action, reducer, meta…). ngxs simplifies a bit but it is still not acceptable.
I developed a state management system taking advantage of TypeScript’s object features. it’s a challenge for me and a lot of fun.
I would like to have some expert opinions on this system. of course, you can also improve it, modify it…
Proposed solution
https://stackblitz.com/edit/angular-ivy-ycnz4n
note 1:
in the environment file we set a DEV mode to true/false
in dev mode, information about the state management is displayed in the console.
note 2:
the information displayed is the following:
part 1:
- the label of action: ADD, REMOVE, UPDATE…
- the model concerned : ICount, IProduct, ITodo…
- item: is the object concerned of (ADD, REMOVE, UPDATE…)
- items: all current state
part 2:
the origin of the action (if it takes place), a click on a button, a page change… -> this point is to be improved
note 3:
the base class is the following : /core/store/base-store.service.ts
note 4:
let’s say we want to manage a new state management
exemple :
we write our model : IProduct (interface of product)
we write a service ‘product-store.service.ts’ which inherits from : /core/store/base-store.service.ts so this new service has the management : ADD, REMOVE, UPDATE
if in this service we have a particular action to do, we add it here :
product-store.service.ts
...
export class StoreProductService extends BaseStoreService<IProduct> {
...
setValided(id: string, isValided: boolean) {
let product: IProduct | undefined = this.values.find((v: IProduct) => v.id === id);
if (product) {
product.isValided = isValided; // do action here
this.update(product, 'VALIDED'); // call update of abstract class
}
}
Alternatives considered
state management
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:5 (1 by maintainers)
Top GitHub Comments
Hello, we reviewed this issue and determined that it doesn’t fall into the bug report or feature request category. This issue tracker is not suitable for support requests, please repost your issue on StackOverflow using tag
angular
.If you are wondering why we don’t resolve support issues via the issue tracker, please check out this explanation.
You need
@rx-angular/state
or@ngrx/component-store