Skip to content

Commit

Permalink
schedule - Add check for typeof window, fallback to throttle if undef…
Browse files Browse the repository at this point in the history
…ined (#712)
  • Loading branch information
thetarnav authored Oct 27, 2024
2 parents 75e3f8e + 5f9c6cd commit c60852d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/fresh-points-join.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@solid-primitives/scheduled": patch
---

Add check for typeof window, fallback to throttle if undefined
2 changes: 1 addition & 1 deletion packages/scheduled/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const throttle: ScheduleCallback = (callback, wait) => {
export const scheduleIdle: ScheduleCallback = isServer
? () => Object.assign(() => void 0, { clear: () => void 0 })
: // requestIdleCallback is not supported in Safari
(window.requestIdleCallback as typeof window.requestIdleCallback | undefined)
(typeof requestIdleCallback !== 'undefined')
? (callback, maxWait) => {
let isDeferred = false,
id: ReturnType<typeof requestIdleCallback>,
Expand Down

0 comments on commit c60852d

Please sign in to comment.