Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Leverage prefetch triggers as hooks to load custom data #56049

Closed
Kumirei opened this issue May 23, 2024 · 2 comments
Closed

Leverage prefetch triggers as hooks to load custom data #56049

Kumirei opened this issue May 23, 2024 · 2 comments
Labels
area: core Issues related to the framework runtime core: defer Issues related to @defer blocks.
Milestone

Comments

@Kumirei
Copy link

Kumirei commented May 23, 2024

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

core

Description

Some components need to fetch data before they can be rendered. Currently we are initializing these calls in the OnInit hook; it would be nice if instead deferrable views with prefetch triggers could be leveraged to dynamically load necessary data ahead of rendering.

Proposed solution

I propose an OnPrefetch hook that components and directives can implement which is called when the component or directive has been pre-fetched in a deferred view. This hook would be called before OnInit.

Alternatives considered

Alternatively a callback could be supplied to the prefetch trigger, which can be used to pre-load the data into a global store.

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime core: defer Issues related to @defer blocks. labels May 28, 2024
@ngbot ngbot bot added this to the needsTriage milestone May 28, 2024
@pkozlowski-opensource
Copy link
Member

Thnx for the suggestion but we are going to pass on this one. The main reason is that we don't think linking data fetching to the defer views. A given component can be used both inside a deferred view and outside of it - it would be very surprising if a component works in one scenario but not in another.

We do some projects planned to look into data fetching more holistically, though.

@pkozlowski-opensource pkozlowski-opensource closed this as not planned Won't fix, can't repro, duplicate, stale Jun 5, 2024
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Jul 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area: core Issues related to the framework runtime core: defer Issues related to @defer blocks.
Projects
None yet
Development

No branches or pull requests

2 participants