-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add an async __unstablePreSavePost
hook; resolving with false prevents saving
#58022
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e684c39
Add an async `__unstablePreSavePost` hook; resolving with false preve…
adamsilverstein f2e65b8
Simplify preSave check
adamsilverstein 101c0d1
Merge branch 'trunk' into add/preSaveHook
adamsilverstein bcae174
Filter edits & enable throwing Error in `__unstablePreSavePost` filter
adamsilverstein da8196e
Merge branch 'trunk' into add/preSaveHook
adamsilverstein ff7d6b4
Pass Promise.resolve( edits ) instead of edits
adamsilverstein 4ead1ff
Move REQUEST_POST_UPDATE_START to before preSave async filter
adamsilverstein d5d7bfc
Update saveEntityRecord error handling to use try/catch
adamsilverstein a546cdd
Merge branch 'trunk' into add/preSaveHook
adamsilverstein 7764b36
Use explicit false check for error
adamsilverstein 2a0d9f2
reduce changes, test functionality, don’t pass data to filter
adamsilverstein 05b4852
whitespace
adamsilverstein File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I'm not wrong we use this technique (a promise filter) because we don't support async actions yet right? Can we implement async action instead?
await doAsyncAction( 'editor.__unstablePreSavePost' )
I have another use-case for this and maybe it's time to fix that once and for all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea. I'm working on this and one little obstacle is that
currentFilter()
/currentAction()
don't make sense any more, because there can be multiple hooks running at the same time.If you use the promise filter technique with sync hooks this problem is invisible. Because the hook merely sets up a promise chain and returns. Only later the actual data will flow through the chain. This will change when
runHook
will start waiting for each promise returned from a handler to resolve.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a draft PR for async hooks: #64204