Enable Signal Store Injection at Module Level #4590
Unanswered
abhidevadiga
asked this question in
Q&A
Replies: 1 comment 4 replies
-
@abhidevadiga, you can provide the SignalStore globally. I do that all the time: export const BookStore = signalStore(
{providedIn: 'root'},
withState({})
) Be aware that NgModules are not really the best fit for a modern Angular application. Nevertheless export const BookStore = signalStore(
withState({})
)
@NgModule({
providers: [BookStore]
})
export class SomeModule {} will also work. |
Beta Was this translation helpful? Give feedback.
4 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Which @ngrx/* package(s) are relevant/related to the feature request?
signals
Information
As a frontend Angular developer exploring Signal Store, I've identified some missing functionalities that could significantly enhance building large-scale applications.
Current Limitation: From my initial understanding, Signal Store appears to be usable only when injected at the component level. In scenarios where components are rendered only after a valid route guard, leveraging Signal Store becomes challenging. Despite attempts to inject Signal Store at the module level within a route guard, it did not function as expected.
Feature Request: To build a scalable architecture, we need the ability to inject Signal Store at the module level to effectively utilize route events and attach side effects, similar to NgRx/effects. This enhancement would allow us to utilize Signal Store methods like we currently use side effects in NgRx.
Current Issue: This feature seems absent in Signal Store, limiting its usability for loading APIs on initial route events and utilizing signal state at the router guard stage, well before the component injects the Signal Store.
Example:
Sample SignalStore
Limitation: Guards are unable to use BookStore because BookStore is first instantiated at the BookComponent.
To resolve this, we need a feature that allows SignalStore to be inject in module level:
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue
Beta Was this translation helpful? Give feedback.
All reactions