Skip to content

Commit

Permalink
Merge pull request #18 from simplifiedcourses/brechtbilliet/fix-conne…
Browse files Browse the repository at this point in the history
…ct-issue-17

fix(connect): fix issue with connect effect
  • Loading branch information
simplifiedcourses authored Apr 19, 2024
2 parents f210dd1 + 82b9bcd commit 73aebfa
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 73aebfa

Please sign in to comment.