Skip to content

馃殌[FEATURE]: Component-level state management#1993

Description

@LuisTovar0

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions