@@ -3,18 +3,14 @@ import {forceImmediateLogging} from '../local-debug'
33import { isMobile , isAndroid } from '../constants/platform'
44import { runAfterInteractions } from './interaction-manager'
55
6- function immediateCallback (
7- cb : ( info : { didTimeout : boolean , timeRemaining : ( ) => number } ) = > void ,
8- deadlineOpts ?: { timeout : number }
9- ) : number {
6+ type TimeoutInfo = { didTimeout : boolean , timeRemaining : ( ) => number }
7+
8+ function immediateCallback ( cb : ( info : TimeoutInfo ) = > void , deadlineOpts ?: { timeout : number } ) : number {
109 cb ( { didTimeout : true , timeRemaining : ( ) => 0 } )
1110 return 0
1211}
1312
14- function timeoutFallback (
15- cb : ( info : { didTimeout : boolean , timeRemaining : ( ) => number } ) = > void ,
16- deadlineOpts ?: { timeout : number }
17- ) : TimeoutID {
13+ function timeoutFallback ( cb : ( info : TimeoutInfo ) = > void , deadlineOpts ?: { timeout : number } ) : TimeoutID {
1814 return setTimeout ( function ( ) {
1915 cb ( {
2016 didTimeout : true ,
@@ -26,7 +22,7 @@ function timeoutFallback(
2622}
2723
2824function runAfterInteractionsFallback (
29- cb : ( info : { didTimeout : boolean , timeRemaining : ( ) => number } ) = > void ,
25+ cb : ( info : TimeoutInfo ) = > void ,
3026 deadlineOpts ?: { timeout : number }
3127) : { cancel : ( ) => void } {
3228 return runAfterInteractions ( function ( ) {
@@ -62,7 +58,7 @@ const cancelIdleCallback = useFallback
6258 : cancelIdleCallbackFallback
6359 : window . cancelIdleCallback . bind ( window )
6460
65- const onIdlePromise = ( timeout : number = 100 ) : Promise < any > =>
61+ const onIdlePromise = ( timeout : number = 100 ) : Promise < TimeoutInfo > =>
6662 new Promise ( resolve => requestIdleCallback ( resolve , { timeout} ) )
6763
6864export { requestIdleCallback , cancelIdleCallback , onIdlePromise }
0 commit comments