How do you add a Pipe provider to a SignalStore, and SignalStore provider to a Service? #4348
Replies: 1 comment
-
I didn't know how to do this, and injection token wasn't working for me I ended up making everything global, so the properties persist in the store (regardless of whether the component is created or not) For the pipe, again, i didn't know how to provide it locally into a store, so just made it global, so I could inject it into the store. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
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
Beta Was this translation helpful? Give feedback.
All reactions