Skip to content

Commit

Permalink
✏️ add scheduleTask() to the API section
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Aug 7, 2024
1 parent ac8f565 commit 4577390
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,20 @@ async function findInFiles(query: string) {
}
```

#### `scheduleTask(callback: () => T, { strategy, signal }): T`

This mimics the API style of `scheduler.postTask()` while providing the extra benefits of `main-thread-scheduling`.

```ts
const controller = new AbortController()
const result = await scheduleTask(() => {
return computeHeavyCalculation()
}, {
strategy: 'smooth',
signal: controller.signal,
})
```

### More complex scenarios

The library has two more functions available:
Expand Down

0 comments on commit 4577390

Please sign in to comment.