ngrx / platform

Reactive State for Angular
https://ngrx.io
Other
8.05k stars 1.98k forks source link

Enable Signal Store Injection at Module Level #4589

Closed abhidevadiga closed 2 weeks ago

abhidevadiga commented 2 weeks ago

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:

  1. Sample SignalStore image

  2. Limitation: Guards are unable to use BookStore because BookStore is first instantiated at the BookComponent. image

  3. To resolve this, we need a feature that allows SignalStore to be inject in module level:

image

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue