question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

your opinions on a state management system

See original GitHub issue

Which @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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
alan-agius4commented, Aug 26, 2021

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.

1reaction
AwesomeObservercommented, Aug 26, 2021

You need @rx-angular/state or @ngrx/component-store

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 things I wish I knew about state management when I started ...
So in my view, state management is the core problem when developing a UI. ... 2) State management is how you update your...
Read more >
What's your opinion on React state management in 2021?
So just curious, what are the community's thoughts on how to best do state management with React? There are a lot of options...
Read more >
React state management: What is it and why to use it?
The state is encapsulated data where you store assets that are persistent between component renderings. The state is just a fancy term for...
Read more >
React doesn't need state management tool, I said
Agree, that's a point and I think it really depends on the need and state architecture of an app. Reducer my in opinion...
Read more >
Understanding State Management in Front-End Paradigm
[For e.g. user, role, permissions, etc.. are called entities in the user management system]; Component(View) state : Filter out these ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found