-
-
Notifications
You must be signed in to change notification settings - Fork 928
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
createMemo should respect the equals value on its initial execution #2362
Comments
But equals by definition compares the last value to the next one. As there is no last value initially, you would have to guard your comparison against it being undefined. In your case, a filter for invalid values should be done within the derivation, not the equals function. |
I know how it works but what is the point of having an initial value if you don't utilize it, if you think about it, it is only logical to use the custom comparator function for the initial execution too. It better aligns with the behavior of a signal and it will reduce clutter as we can rely on the equals function to validate the next value, avoiding unnecessary conditionals. |
createMemo cannot know if you are intending to use the initial value or not. |
Please can you elaborate because I am not sure if I understand what do you mean by this sentence? If current behaviour is OK, then what is the purpose of the initial value? More importantly what difference does it make if |
This was merely an answer to your statement that having an initial value was pointless if you're not using it. But that's merely your preference based on a single case. In Solid, Ryan usually aims for the most helpful, predictable and performant behavior. Since an initial equality comparison without a previous value will be unhelpful except for very few edge cases, totally unexpected and easily provoking errors and provides the worse performance, he chose not to apply it. |
A memo accept an initial value and the
equals
property via theoptions
object to exert finer control over its update logic. However it does not respect the equals property on its initial execution but it should for consistency.For the following example,
'some value'
should never be assigned to the memo as it is not a valid value.The text was updated successfully, but these errors were encountered: