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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: rewardEarly mode #2

Merged
merged 3 commits into from
Apr 15, 2024

Conversation

renatodeleao
Copy link
Collaborator

Summary

The PR was made to upstream but the library is not maintained anymore, so making the same PR to our fork so that we can move on with our life.

vuelidate#1240

closes vuelidate#1237

1. Moved $lastInvalid assignment from the results.$invalid computed
   because computed props should be side-effect free.
2. Added $lastCommittedOn as a watch source because 3.4.x vue will cache
   computed more aggressively and $lastInvalidState would be out of sync
   in the "commit() when valid" scenario:
   - commit() sets $lastInvalidState to true
   - validators run and return invalid as false
   - result.$invalid is already false, so it will not recompute (cached)
   - the watcher will not be triggered because $result.$invalid dep did
     not change.
   - last $invalidState is not set to false, and thus $model change
     triggers validators to run.
   I don't know if it's out-of-scope of this PR to update vue, but 3.4.x
   brought many changes to computed optimization which vuelidate relies on
   heavily and it's the future.
3. flush "post" is required for async validators to work in this mode, otherwise
   last invalid state will be flipped to false since sync validators run first
   and turn invalid to false "before" pending is set to true and it will prevent
   them from running (Guessing). At least is required for 3.4.x and that's
   the version the majority should be using.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants