Skip to content

Commit

Permalink
enhance: More robust requestIdleCallback wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
ntucker committed Jun 22, 2024
1 parent 16f35f6 commit 8aabe18
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/spotty-humans-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@data-client/react': patch
---

More robust requestIdleCallback wrapper
5 changes: 2 additions & 3 deletions packages/react/src/managers/NetworkManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ import { NetworkManager } from '@data-client/core';
export default class WebNetworkManager extends NetworkManager {
static {
if (typeof requestIdleCallback === 'function') {
WebNetworkManager.prototype.idleCallback = requestIdleCallback.bind(
typeof window !== 'undefined' ? window : globalThis,
);
WebNetworkManager.prototype.idleCallback = (...args) =>
requestIdleCallback(...args);
}
}
}

0 comments on commit 8aabe18

Please sign in to comment.