ngrx / platform

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

How do you add a Pipe provider to a SignalStore, and SignalStore provider to a Service? #4345

Closed dreamstar-enterprises closed 1 month ago

dreamstar-enterprises commented 1 month ago

Which @ngrx/* package(s) are relevant/related to the feature request?

store

Information

Pipe into SignalStore I can add one easily to a component, via providers I can inject a service A into another service B too (provided service B is available globally) But I want to use const datePipe = inject(DatePipe) in a signalstore (a built in angular pipe) Is there anyway of providing it into a signalstore, or making it available globally?

SignalStore into Service Similarly, I want to do this for a signalstore too, into a service. This is because, my signalStore has a onInitHook which runs functions everytime the component loads. So, I provide the signalStore only to the component (not the root). If I provided it at the root, it would only initialise once, when the entire app refreshes, and the onInithook functions wouldn't re-run when a component loads / re-loads.

However, at the same time when I make an api call, when a service gets a new object from a database, the service needs to reset certain properties of the signalStore state (after a successful api call) For it to do that the service needs access to the signalStore - but there is no way of providing a signalStore to the service (at least from what I could tell fro all the reading I have done)

Describe any alternatives/workarounds you're currently using

No response

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