Skip to content

Commit

Permalink
✏️ improve paragraph
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Jan 17, 2024
1 parent da165de commit 25b79b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ There are three scheduling strategies available. You can think about them more e

[`scheduler.postTask()`](https://developer.mozilla.org/en-US/docs/Web/API/Scheduler/postTask) is available in some browsers today. `postTask` is a great alternative, you just need to have a better understanding on its inner workings. `main-thread-scheduling` aims to be easier to use. For example, `main-thread-scheduling` uses the `isInputPending()` API to ensure the UI doesn't freeze when the user interacts with the page (if you use `scheduler.postTask()` you will need to do that manually). Also, if you have running animations while running your tasks, you will see `main-thread-scheduling` perform better.

If you want the benefits of `main-thread-scheduling`, but you prefer the `postTask()` API/thinking model, then here is an implementation of `postTask()` using `yieldOrContinue()`:
If you want the benefits of `main-thread-scheduling`, but you prefer the callback based `postTask()` API/thinking model, then here is an implementation of `postTask()` using `yieldOrContinue()`:
```ts
async function postTask(callback: () => void | Promise<void>) {
await yieldOrContinue('interactive')
Expand Down

0 comments on commit 25b79b5

Please sign in to comment.