Skip to content

Answer:65#1464

Open
phhien203 wants to merge 2 commits intotomalaforge:mainfrom
phhien203:phhien203-signal-forms
Open

Answer:65#1464
phhien203 wants to merge 2 commits intotomalaforge:mainfrom
phhien203:phhien203-signal-forms

Conversation

@phhien203
Copy link
Copy Markdown

✅ Challenge Submission Checklist

Start your PR title with: Answer:${challenge_number}

⚠️ Important Notice

If you would like personal feedback or a detailed review, please support the project on GitHub:

You can also submit a PR without sponsorship to:

  • Be listed among the answered challenges, or
  • Receive a review from a community member. 🔥

this.userModel.set(userValue);
} else {
this.userForm.reset({ firstname: '', lastname: '', age: 0, grade: 0 });
this.userModel.set({ firstname: '', lastname: '', age: 0, grade: 0 });
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I created this challenge because you can avoid effect thanks to signal forms.
You should look at linkedSignals.

Everything should happen in the creation of userModel

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I updated the code to use linkedSignal.

grade: 0,
};
}
});
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes a lot nicer, isn't it

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's right!

const hasValue = this.userResource.hasValue();
const user = this.userResource.value();

if (hasValue && user) {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @tomalaforge , do you think it's ok to only check if (user) instead of if (hasValue && user)?

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, hasValue do !!user() so it's kind of the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

65 answer answer sponsor sponsor the project to be reviewed PR requests a review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants