You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can you provide an example of how the usage of arrays with deep signals within the SignalStore/State should look like? How the state update would look like?
Can you provide an example of how the usage of arrays with deep signals within the SignalStore/State should look like? How the state update would look like?
@markostanimirovic Sure! Doing a quick comparison with records. When T extends a record:
typeDeepSignal<TextendsRecord<any,any>>=Signal<T>&{[KinkeyofT]: DeepSignal<T[K]>};interfacePerson{name: string;}constdeepPersonSignal: DeepSignal<Person>=/**/;deepPersonSignal();// Type: Person, emits reactively the person object.deepPersonSignal.name();// Type: string, signal that emits reactively the name.
My proposal, when the generic is an array, would be having this:
typeDeepSignal<TextendsR[]>=Signal<R[]>&{[KinkeyofT]: DeepSignal<T[K]>}&{length: Signal<number>,entries: Signal<IterableIterator<[number,R]>>,keys: Signal<IterableIterator<number>>,values: Signal<IterableIterator<R>>};constdeepPersonsSignal: DeepSignal<Person[]>=/**/;deepPersonsSignal();// Type: Person[], emits reactively the person array.deepPersonsSignal[0]();// Type: Person, signal that emits reactively the first element of the array.deepPersonsSignal[0].name();// Type: string, signal that emits reactively the name of the first element.
It'd be ideal that the deep signal of arrays didn't emit if only values are updated, but the array length is the same. As pointed out by @alxhub it would enhance the performance of @for control flow.
Which @ngrx/* package(s) are relevant/related to the feature request?
signals
Information
Right now deep signals only support record-like signals. Ideally it would also support array-like structures, providing the same “deep” behavior.
It would be more tricky, since it’d need to proxy mutation operations, but should be technically possible.
Describe any alternatives/workarounds you're currently using
No response
I would be willing to submit a PR to fix this issue
The text was updated successfully, but these errors were encountered: