requestIdleCallback
Refer to README.md for more information what's the overall strategy and why we're migrating away from InteractionManager.runAfterInteractions.
Strategy
Use requestIdleCallback for non-urgent background work
Pusher subscriptions, typing event listeners, search API calls, and contact imports are non-urgent background work. They should not block rendering or animations. requestIdleCallback schedules them during idle periods.
1. Realtime Subscriptions
| File |
Line |
Current |
Migration |
PR |
Pusher/index.ts |
206 |
InteractionManager wrapping subscribe call |
Replace with requestIdleCallback(() => subscribe()) |
#53751 |
Pusher/index.native.ts |
211 |
InteractionManager wrapping subscribe call |
Replace with requestIdleCallback(() => subscribe()) |
#56610 |
UserTypingEventListener.tsx |
35 |
InteractionManager wrapping unsubscribe |
Replace with requestIdleCallback(() => unsubscribe()) |
#39347 |
UserTypingEventListener.tsx |
49 |
Store ref for InteractionManager handle |
Update to store requestIdleCallback handle ref |
#39347 |
UserTypingEventListener.tsx |
59 |
InteractionManager wrapping subscribe |
Replace with requestIdleCallback(() => subscribe()) |
#39347 |
UserTypingEventListener.tsx |
70 |
InteractionManager wrapping unsubscribe |
Replace with requestIdleCallback(() => unsubscribe()) |
#39347 |
2. Search API Operations
| File |
Line |
Current |
Migration |
PR |
useSearchHighlightAndScroll.ts |
126 |
InteractionManager deferring search API call |
Try to use requestIdleCallback(() => search(...)) or startTransition to defer the search API call |
#69713 |
useSearchSelector.native.ts |
27 |
InteractionManager deferring contact import |
Try to use requestIdleCallback(importAndSaveContacts) or startTransition to defer the contact import |
#70700 |
MoneyRequestParticipantsSelector.tsx |
431 |
InteractionManager deferring contact import |
Use requestIdleCallback(importAndSaveContacts) or startTransition to defer the contact import |
#54459 |
requestIdleCallback
Refer to README.md for more information what's the overall strategy and why we're migrating away from
InteractionManager.runAfterInteractions.Strategy
Use
requestIdleCallbackfor non-urgent background workPusher subscriptions, typing event listeners, search API calls, and contact imports are non-urgent background work. They should not block rendering or animations.
requestIdleCallbackschedules them during idle periods.1. Realtime Subscriptions
Pusher/index.tsrequestIdleCallback(() => subscribe())Pusher/index.native.tsrequestIdleCallback(() => subscribe())UserTypingEventListener.tsxrequestIdleCallback(() => unsubscribe())UserTypingEventListener.tsxrequestIdleCallbackhandle refUserTypingEventListener.tsxrequestIdleCallback(() => subscribe())UserTypingEventListener.tsxrequestIdleCallback(() => unsubscribe())2. Search API Operations
useSearchHighlightAndScroll.tsrequestIdleCallback(() => search(...))orstartTransitionto defer the search API calluseSearchSelector.native.tsrequestIdleCallback(importAndSaveContacts)orstartTransitionto defer the contact importMoneyRequestParticipantsSelector.tsxrequestIdleCallback(importAndSaveContacts)orstartTransitionto defer the contact import