@ngrx/signals DeepSignal not created when patching state
Closed this issue · 4 comments
Which @ngrx/* package(s) are relevant/related to the feature request?
signals
Information
DeepSignals
are only created when defining initial state using withState
. When I'm using patchState
inside onInit
hook DeepSignal
isn't created.
I want to be able to set empty object as placeholder inside state, and then in onInit
hook replace this placeholder with result of factory function injected by dependency injection (factory fn takes reference to store as argument). Result from factory would be patched into state. I'm expecting it to be DeepSignal
, but it isn't. It's worth to note that it is typed by signal store as DeepSignal
.
Real world usage could be find here: https://github.com/k3nsei/ngx-signal-store-query/blob/main/libs/ngx-signal-store-query/src/with-query.ts
So here https://github.com/k3nsei/ngx-signal-store-query/blob/1cb2edb83ddd46ed6e3017e3d75d7714d31e572e/apps/demo/src/app/app.component.ts#L49 instead of current implementation, it would be nice to be able to use something like:
protected readonly data = this.githubQuery.data;
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue
- Yes
- No
@ k3nsei, could you create a minimal and reproducible example on StackBlitz? If some investigation is required, that would help us a lot.
Here's the template: https://stackblitz.com/edit/ngrx-seed
Provided seed was for NGRX so I created my own here as issue is related to Signal Store.
https://stackblitz.com/edit/stackblitz-ng-signal-sore-9aq8nt-fvbemt?file=src%2Fmain.ts
@k3nsei Sorry, that's the official one https://stackblitz.com/github/ngrx/signal-store-starter?file=src%2Fmain.ts but if you have created your one own, that's fine as well.
Btw. both seeders are shown when you create a new issue
@k3nsei I am going to move this to discussion, okay? If it turns out we have here a bug or feature request, we can create a new one.