-
-
Notifications
You must be signed in to change notification settings - Fork 245
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
Asyncified validate + submit flow #711
Conversation
Codecov Report
@@ Coverage Diff @@
## v3 #711 +/- ##
==========================================
+ Coverage 97.96% 98.02% +0.05%
==========================================
Files 162 162
Lines 1669 1668 -1
Branches 604 602 -2
==========================================
Hits 1635 1635
Misses 8 8
+ Partials 26 25 -1
Continue to review full report at Codecov.
|
During benchmarks, it turned out that making everything async has one flaw: Another problem araised while working with rejected promises. The thing is that it's not better than |
Let's start with a short flashback from #644:
This not very elegant solution got implemented in #51. Why it's not elegant? Because it's redundant. There's no need for such hooks if one can simply add it directly to the
onSubmit
. Another problem (non-elegancy) is the asynchronous validation - invented in #17 and implemented in 4a56596. It's weird and is using callbacks.This PR introduces a new, clean flow (including #711 (comment)):
onValidate
is now(model, error?) => error? | Promise<error?>
. This is far better and obvious than the callback version before.onSubmitSuccess
andonSubmitFailure
. I'm pretty sure there's no viable case for them at all. Migration is straightforward:submitting
andvalidating
states. Nowvalidating
istrue
only while the bridge validator oronValidate
are currently running. Same forsubmitting
- it's try only whileonSubmit
is running.TODO:
CHANGELOG.md
.Closes #644.