Skip to content

Add "delay" parameter to the "idle" trigger #57814

@e-oz

Description

@e-oz

Which @angular/* package(s) are relevant/related to the feature request?

compiler

Description

Please add the "delay" parameter to the "idle" trigger.
We could use it like this:

@defer (on hover(container); on idle(2000)) {
  <heavy-component/>
}

or this:

@defer (on idle({delay: 2000})) {
  <heavy-component/>
}

That would load the HeavyComponent either on hover or after a 2s delay after “idle”.

There are just components that are far enough from the user’s path, and heavy enough to load them not on just “idle”, but with a small delay - because more important components will take a chance to be loaded on “idle”.

Proposed solution

Please add the "delay" parameter to the "idle" trigger.

Alternatives considered

We can do this, but it is considered a bad practice by Angular.dev:

@defer (on idle) {
  @defer(on timer(2000)) {
    <heavy-component/>
  }
}

Also, this way we can't combine triggers with "or" logic.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: coreIssues related to the framework runtimecore: deferIssues related to @defer blocks.

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions