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

Introduce withSyncEvent action wrapper utility and proxy event object whenever it is not used #68097

Open
wants to merge 22 commits into
base: trunk
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
60448fe
Implement withSyncEvent action wrapper utility.
felixarntz Dec 18, 2024
dba93ec
Prepare Interactivity API infrastructure for awareness of action prio…
felixarntz Dec 18, 2024
5201460
Merge branch 'trunk' into add/64944-with-sync-event
felixarntz Jan 2, 2025
dad7083
Proxy event object when withSyncEvent() is not used.
felixarntz Jan 2, 2025
524bf72
Merge branch 'trunk' into add/64944-with-sync-event
felixarntz Jan 21, 2025
21e51be
Ensure generator functions using withSyncEvent() are wrapped correctl…
felixarntz Jan 21, 2025
a582f01
Update Interactivity API documentation to reference withSyncEvent().
felixarntz Jan 21, 2025
5d68fcb
Use withSyncEvent() in all built-in actions that require it.
felixarntz Jan 21, 2025
d5de596
Merge branch 'trunk' into add/64944-with-sync-event
felixarntz Jan 22, 2025
621a9c9
Minor fixes for withSyncEvent docs.
felixarntz Jan 22, 2025
8a15886
Merge branch 'trunk' into add/64944-with-sync-event
felixarntz Jan 29, 2025
ec3d662
Clarify documentation.
felixarntz Jan 29, 2025
b183fcd
Merge branch 'add/64944-with-sync-event' of github.com:WordPress/gute…
felixarntz Jan 29, 2025
bf3dbcc
Enhance withSyncEvent implementation and ensure the sync flag is main…
felixarntz Jan 29, 2025
2dd6eab
Add doc block for wrapEventAsync().
felixarntz Jan 29, 2025
682ee6f
Use more specific types for event proxy handler.
felixarntz Jan 29, 2025
dff811c
Merge branch 'trunk' into add/64944-with-sync-event
felixarntz Feb 10, 2025
f0fa92a
Amend callback in withSyncEvent instead of wrapping it.
felixarntz Feb 10, 2025
21f96c4
Merge branch 'trunk' into add/64944-with-sync-event
felixarntz Feb 12, 2025
524b30d
Merge branch 'trunk' into add/64944-with-sync-event
felixarntz Feb 13, 2025
2fbfd0e
Revert "Prepare Interactivity API infrastructure for awareness of act…
felixarntz Feb 13, 2025
0dbd15f
Update evaluate() to no longer invoke functions (except where needed …
felixarntz Feb 13, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor fixes for withSyncEvent docs.
  • Loading branch information
felixarntz committed Jan 22, 2025
commit 621a9c9eba00c69edaab5ebc89be2ccd93b8954a
4 changes: 2 additions & 2 deletions docs/reference-guides/interactivity-api/api-reference.md
Original file line number Diff line number Diff line change
@@ -1258,7 +1258,7 @@ store( 'mySliderPlugin', {

### withSyncEvent()

Actions that require synchronous event access need to use the `withSyncEvent()` function to wrap their handler callback. This is necessary due to an ongoing effort to handle store actions asynchronously by default, unless they require synchronous event access. Therefore, as of Gutenberg `TODO: Add release number here!` / WordPress 6.8 all actions that require synchronous event access should use the `withSyncEvent()` utility wrapper function. Otherwise a deprecation warning will be triggered, and in a future release the behavior will change accordingly.
Actions that require synchronous access to the `event` object need to use the `withSyncEvent()` function to wrap their handler callback. This is necessary due to an ongoing effort to handle store actions asynchronously by default, unless they require synchronous event access. Therefore, as of Gutenberg `TODO: Add release number here!` / WordPress 6.8 all actions that require synchronous event access need to use the `withSyncEvent()` utility wrapper function. Otherwise a deprecation warning will be triggered, and in a future release the behavior will change accordingly.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The TODO here can only be addressed once this is ready for merge and we know which Gutenberg version this will be released in.


Only very specific event methods and properties require synchronous access, so it is advised to only use `withSyncEvent()` when necessary. The following event methods and properties require synchronous access:

@@ -1267,7 +1267,7 @@ Only very specific event methods and properties require synchronous access, so i
* `event.stopImmediatePropagation()`
* `event.stopPropagation()`

Here is an example, where one action requires synchronous event access while the other one does not:
Here is an example, where one action requires synchronous event access while the other actions do not:

```js
// store