Skip to content

Commit

Permalink
refactor(react): rename util function
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Dec 18, 2023
1 parent a7bf255 commit 03d899d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .yarn/versions/a2d39008.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declined:
- "@codemirror-toolkit/react"
4 changes: 2 additions & 2 deletions packages/react/src/utils/asyncScheduler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
type CancelTask = () => void

function runTask(callback: () => void): CancelTask {
function queueTask(callback: () => void): CancelTask {
let task: typeof callback | null = callback
queueMicrotask(() => task?.())
return () => (task = null)
Expand All @@ -14,7 +14,7 @@ interface AsyncScheduler {
export function createAsyncScheduler(): AsyncScheduler {
let cancelTask: CancelTask | undefined
return {
request: (callback) => (cancelTask = runTask(callback)),
request: (callback) => (cancelTask = queueTask(callback)),
cancel: () => cancelTask?.(),
}
}

0 comments on commit 03d899d

Please sign in to comment.