Skip to content

Commit 4577390

Browse files
committed
✏️ add scheduleTask() to the API section
1 parent ac8f565 commit 4577390

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

readme.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,20 @@ async function findInFiles(query: string) {
8484
}
8585
```
8686

87+
#### `scheduleTask(callback: () => T, { strategy, signal }): T`
88+
89+
This mimics the API style of `scheduler.postTask()` while providing the extra benefits of `main-thread-scheduling`.
90+
91+
```ts
92+
const controller = new AbortController()
93+
const result = await scheduleTask(() => {
94+
return computeHeavyCalculation()
95+
}, {
96+
strategy: 'smooth',
97+
signal: controller.signal,
98+
})
99+
```
100+
87101
### More complex scenarios
88102

89103
The library has two more functions available:

0 commit comments

Comments
 (0)