Skip to content

Commit

Permalink
✨ new afterFrame() scheduling utility
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Aug 23, 2023
1 parent 9a83445 commit 9c4d543
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export { default as isTimeToYield } from './src/isTimeToYield'

// utility
export { default as queueTask } from './src/queueTask'
export { default as afterFrame } from './src/afterFrame'
7 changes: 7 additions & 0 deletions src/afterFrame.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import queueTask from './queueTask'

export default function afterFrame(callback: () => void): void {
requestAnimationFrame(() => {
queueTask(callback)
})
}

0 comments on commit 9c4d543

Please sign in to comment.