Skip to content

Commit

Permalink
🐜 rename waitHiddenTask() β†’ waitNextTaskWhileHidden()
Browse files Browse the repository at this point in the history
  • Loading branch information
astoilkov committed Jul 9, 2024
1 parent b41e8ba commit dfdbe6a
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/WorkCycleTracker.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import frameTracker from './frameTracker'
import waitHiddenTask from './utils/waitHiddenTask'
import waitNextTaskWhileHidden from './utils/waitNextTaskWhileHidden'
import type SchedulingTask from './SchedulingTask'

export default class WorkCycleTracker {
Expand All @@ -23,7 +23,7 @@ export default class WorkCycleTracker {
if (task.type === 'frame-based') {
// we use waitHiddenTask() because requestAnimationFrame() doesn't
// fire when page is hidden
await Promise.race([frameTracker.waitAfterFrame(), waitHiddenTask()])
await Promise.race([frameTracker.waitAfterFrame(), waitNextTaskWhileHidden()])
} else if (task.type === 'idle-based') {
if (typeof requestIdleCallback === 'undefined') {
// todo: use waitHiddenTask() with a timeout
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const state = {
hiddenTask: withResolvers(),
}

export default async function waitHiddenTask(): Promise<void> {
export default async function waitNextTaskWhileHidden(): Promise<void> {
if (document.visibilityState === 'hidden') {
await waitNextTask()

Expand Down

0 comments on commit dfdbe6a

Please sign in to comment.