-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed: AbortSignal to work with react native and old browsers
- Loading branch information
1 parent
9e88a3c
commit f1c7e3c
Showing
3 changed files
with
14 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
export function createTimeoutSignal(timeoutMs: number): AbortSignal { | ||
if (typeof AbortSignal.timeout === 'function') { | ||
// Use native timeout if available (modern browsers) | ||
return AbortSignal.timeout(timeoutMs) | ||
} else { | ||
// Fallback for React Native and older browsers | ||
const controller = new AbortController() | ||
setTimeout(() => controller.abort(), timeoutMs) | ||
return controller.signal | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters