Skip to content

Commit

Permalink
fix(connect): fix issue with connect effect
Browse files Browse the repository at this point in the history
connect should act on each key independently
  • Loading branch information
Brecht Billiet authored and Brecht Billiet committed Apr 19, 2024
1 parent f210dd1 commit 82b9bcd
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions projects/ngx-signal-state/src/lib/signal-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,16 +111,16 @@ export class SignalState<T extends Record<string, unknown>> {
*/
public connect(partial: Partial<{ [P in keyof T]: Signal<T[P]> }>): void {
this.throwOrReturnSignals();
effect(
() => {
Object.keys(partial).forEach((key: keyof T) => {
Object.keys(partial).forEach((key: keyof T) => {
effect(
() => {
const v = partial[key] as Signal<keyof T>;
this.patch({ [key]: v() } as Partial<T>);
});
},
// This will update the state, so we need to allow signal writes
{ allowSignalWrites: true }
);
},
// This will update the state, so we need to allow signal writes
{ allowSignalWrites: true }
);
});
}

/**
Expand Down

0 comments on commit 82b9bcd

Please sign in to comment.