Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚀[FEATURE]: Component-level state management #1993

Open
LuisTovar0 opened this issue Apr 11, 2023 · 2 comments
Open

🚀[FEATURE]: Component-level state management #1993

LuisTovar0 opened this issue Apr 11, 2023 · 2 comments

Comments

@LuisTovar0
Copy link

Relevant Package

This would probably be a new package, called @ngxs/component or @ngxs/component-store

Description

Currently, it doesn't seem possible to manage state at the component level.

In other words, this would be a store with a lifecycle that matches a component's lifecycle, while being independent from the global store.

Describe the problem you are trying to solve

I was managing the state of a component using the shared store. I realized I will need more than one instance of this component to be rendered at some point. However, they cannot share the same store: they each need their own store to write and read from. So they need to manage their states locally.

Describe the solution you'd like

Something like @ngrx/component-store. That is, a Store component that can be created -- with all the reducers and selectors -- and then be injected into a component that wants to use it, so this component can initialize it and pass it around as needed.

Describe alternatives you've considered

I've considered:

Despite there being working alternatives, a solution with the NGXS philosophy would be better. After all, NGXS exists because it's a better/more modern alternative to NGRX.

@dhutaryan
Copy link

Agree. It would be a great feature. Would want to have it 2 years ago 🙂

@markwhitfeld
Copy link
Member

markwhitfeld commented May 16, 2023

We have an open RFC for this.
We would love to hear your feedback and/or ideas on this: #1979

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants