Skip to content

Commit 93d83c3

Browse files
committed
Update docs to note splitTask being exported
1 parent 0b1c7b0 commit 93d83c3

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

docs/reference-guides/interactivity-api/api-reference.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,8 @@ const { state } = store("myPlugin", {
813813
As mentioned above with [`wp-on`](#wp-on), [`wp-on-window`](#wp-on-window), and [`wp-on-document`](#wp-on-document), an async action should be used whenever the `async` versions of the aforementioned directives cannot be used due to the action requiring synchronous access to the `event` object. Synchronous access is reqired whenever the action needs to call `event.preventDefault()`, `event.stopPropagation()`, or `event.stopImmediatePropagation()`. To ensure that the action code does not contribute to a long task, you may manually yield to the main thread after calling the synchronous event API. For example:
814814

815815
```js
816-
function toMainThread() {
816+
// Note: In WordPress 6.6 this splitTask function is exported by @wordpress/interactivity.
817+
function splitTask() {
817818
return new Promise(resolve => {
818819
setTimeout(resolve, 0);
819820
});
@@ -823,7 +824,7 @@ store("myPlugin", {
823824
actions: {
824825
handleClick: function* (event) {
825826
event.preventDefault();
826-
yield toMainThread();
827+
yield splitTask();
827828
doTheWork();
828829
},
829830
},

0 commit comments

Comments
 (0)