NgRx Signal Store: functions inside OnInit hook, don't run when store is injected into normal service
dreamstar-enterprises opened this issue · comments
Which @ngrx/* package(s) are the source of the bug?
store
Minimal reproduction of the bug/regression with instructions
I'm not sure if this was by design or intentionaly, but when I inject a signal store into a normal service, the functions inside onInit do not run.
If the inject the signal store into a component, it works fine.
If this is not by design - I think it's a bug
If it is by design - may be a bit risky? As depending on whether it's injected into a component or service, the behaviour, and initialisation of the store will be different (won't happen in case an into service injection)
Expected behavior
lifecycle hooks should run whether injected into a service or component
Versions of NgRx, Angular, Node, affected browser(s) and operating system(s)
NgRX Signal Store
IDE - JetBrains Ultimate IDEA
Other information
No response
I would be willing to submit a PR to fix this issue
- Yes
- No
I ended up drawing a massive diagram of 20 services in Lucid Chart and found one circular injection. I think that solved the problem. So, I think the onInit hook works, in both components and services - I've not actually tested this, as I ended providing the store into a component instead, rather than service.