Support optional timeout for idle deferred triggers#67190
Support optional timeout for idle deferred triggers#67190thePunderWoman merged 3 commits intoangular:mainfrom
Conversation
|
@SkyZeroZx requestIdleCallback's options currently only have |
Good point, we can create a migration if that happens, then I'll continue with |
fa1fa0c to
deeca94
Compare
deeca94 to
3ac06c9
Compare
IdleService now accepts IdleRequestOptions, enabling configuration of requestIdleCallback behavior in compatible environments.
Allows specifying a timeout parameter for idle-based deferred triggers, enabling more granular control over when deferred actions are executed. Closes angular#67187
Extends language service parsing and validation to support `@defer on idle(300)`
3ac06c9 to
5b34da7
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request adds support for an optional timeout for idle deferred triggers, a valuable feature for controlling when deferred content loads. The implementation is well-structured, involving a significant refactoring of IdleScheduler to use option-based buckets, which is key for handling different requestIdleCallback options. The related services, compiler instructions, and language service have been updated accordingly. The changes are well-tested with new unit, integration, and golden file tests. I have one suggestion to improve code clarity in the IdleScheduler.
|
This PR was merged into the repository. The changes were merged into the following branches:
|
This change allows supply a timeout value in the on idle trigger of an Angular
@deferblock, which translates into passing thetimeoutoption torequestIdleCallback.That way, if the browser doesn’t schedule the callback soon enough, the work will run no later than the specified timeout in options
Closes #67187
Usage
@defer (on idle(500)) { <heavy-component /> } @defer (prefetch on idle(500)) { <heavy-component /> } @defer (hydrate on idle(500)) { <heavy-component /> }Other information
IdleSchedulerto group callbacks and avoid redundant idle schedulingIdleRequestOptionssupport toIdleService@defer idle(300)syntax