Skip to content

Commit

Permalink
🧪 add scheduleTask() method to the playground
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Mar 18, 2024
1 parent 5c1ed84 commit 5a7bbce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<button id="run-idle">idle</button>
<button id="run-all-sequential">run all (sequential)</button>
<button id="run-all-parallel">run all (parallel)</button>
<button id="schedule-task">scheduleTask()</button>
</div>
<br />
<div>
Expand Down
8 changes: 8 additions & 0 deletions playground/playground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import simulateWork from './utils/simulateWork'
import waitNextTask from '../src/utils/waitNextTask'
import withResolvers from '../src/utils/withResolvers'
import fps from './utils/fps'
import scheduleTask from '../src/scheduleTask'

document.querySelector('#run-interactive')!.addEventListener('click', () => {
run('interactive')
Expand All @@ -27,6 +28,13 @@ document.querySelector('#run-all-parallel')!.addEventListener('click', async ()
run('smooth', 2000)
run('idle', 3000)
})
document.querySelector('#schedule-task')!.addEventListener('click', async () => {
const result = await scheduleTask(() => {
simulateWork()
return 'scheduleTask() completed'
})
console.log(result)
})
document.querySelector('#simulate-work')!.addEventListener('click', async () => {
simulateWork()
})
Expand Down

0 comments on commit 5a7bbce

Please sign in to comment.