Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Answer: 50: Bug in effect solution #856

Closed

Conversation

svenson95
Copy link
Contributor

Here is my solution for this challenge. It was very interesting to investigate the problem and understand what is happening here. I've made some comments explaining my thought process, feel free to correct me 馃槃

@tomalaforge tomalaforge changed the title Answer 50: Bug in effect solution Answer: 50: Bug in effect solution May 7, 2024
@tomalaforge tomalaforge added answer answer 50 bug signal effect: effect not triggered contributor highly contributing to the project to be reviewed PR requests a review labels May 7, 2024
@tomalaforge
Copy link
Owner

yes that's one solution,
I think I prefer to have one signal per effect, easier to read, easier to maintain
or maybe create a computed signal and listen to this one in the effect.

@tomalaforge tomalaforge removed the to be reviewed PR requests a review label May 7, 2024
With this all signal values are interpreted as relevant values for this effect.
So if any of these values changes, the effect will run.
*/
const name = this.name();
Copy link
Sponsor Contributor

@LMFinney LMFinney May 8, 2024

Choose a reason for hiding this comment

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

With this implementation, the alert will be shown when you have 2 or 3 of them checked, and then you uncheck one (because name || age || address will still be true if any of them are true). I think that's not what @tomalaforge wants. I think he wants the alert to show when each checkbox is checked, independent of the state of any other, but not as the result of unchecking.

Thomas can clarify, of course.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes but i wasn't really sure what is part of the challenge and what's not. This is the simplest solution without changing the code a lot. As thomas already mentioned, this could be solved with a computed signal as well. I already have some things in mind, i'll update the docs for this challenge.

Copy link
Sponsor Contributor

Choose a reason for hiding this comment

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

I think we need clarification on the requirements.

Copy link
Owner

Choose a reason for hiding this comment

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

@LMFinney you are right, but I didn't go that far 馃槄
My goal was to trigger the effect when we check or uncheck one checkbox which is not the case if the first one is true. But I didn't think of your case @LMFinney; So I should change the instruction to be clearer indeed 馃憤

@svenson95
Copy link
Contributor Author

yes that's one solution, I think I prefer to have one signal per effect, easier to read, easier to maintain or maybe create a computed signal and listen to this one in the effect.

i'll add this as a bonus step in the challenge, and update my solution afterwards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
50 bug signal effect: effect not triggered answer answer contributor highly contributing to the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants