-
Notifications
You must be signed in to change notification settings - Fork 297
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
Update invariant use within datastore generator functions #1941
Comments
@felixarntz moving this forward to AC as there are still quite a few of these in the codebase. |
@felixarntz please review the ACs here as well. You can see what the proposed changes look like with one action here: |
@aaemnnosttv I like the approach you're suggesting, great! IB ✅ |
@aaemnnosttv just checking this should be a |
Yep, thanks @wpdarren – I've added it now 👍 |
QA ✅ |
Bug Description
In #1801 we updated the way
createFetchStore
works internally so that invalid use raises errors as expected.As discovered in that issue, the main problem is that errors raised in a generator function do not throw but instead result in a rejected promise which is not handled well.
We still have many instances of
invariant
used within generators in the datastore outside of thecreateFetchStore
use.E.g.
site-kit-wp/assets/js/googlesitekit/modules/datastore/modules.js
Lines 181 to 183 in 62c8243
Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
createValidatedAction
utility should be created for simplifying the definition of an async action that has validationvalidate
(a non-generator function),actionCreator
(a function which may or may not be a generator that returns and/or yields actions)invariant
) should be updated to use the new utilityImplementation Brief
createValidatedAction
QA Brief
invariant
internallyChangelog entry
The text was updated successfully, but these errors were encountered: