You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Each state (service decorated with @State() decorator) must be injectable and has to have @Injectable() decorator. State is registered within service container with NGXS module.
However, there are times when we would like to process of initialisation/construction of states using service factory, which means that @Injectable() decorator is not of interest.
If given tokens are part of public API, this edge case could be supported as well.
Describe the problem you are trying to solve
Register state class within service container using service factory.
Describe the solution you'd like
ROOT_STATE_TOKEN and FEATURE_STATE_TOKEN as public injection tokens.
Describe alternatives you've considered
Complex initialisation of state services is not possible without service factory, so no viable alternative exist, that is, registered service would have more complexity than necessary.
This discussion was converted from issue #1984 on September 12, 2023 17:51.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Relevant Package
This feature request is for @ngxs/store
Description
Each state (service decorated with @State() decorator) must be injectable and has to have @Injectable() decorator. State is registered within service container with NGXS module.
However, there are times when we would like to process of initialisation/construction of states using service factory, which means that @Injectable() decorator is not of interest.
If given tokens are part of public API, this edge case could be supported as well.
Describe the problem you are trying to solve
Register state class within service container using service factory.
Describe the solution you'd like
ROOT_STATE_TOKEN and FEATURE_STATE_TOKEN as public injection tokens.
Describe alternatives you've considered
Complex initialisation of state services is not possible without service factory, so no viable alternative exist, that is, registered service would have more complexity than necessary.
Beta Was this translation helpful? Give feedback.
All reactions