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

@placeholder vs @loading #54685

Closed
eluchsinger opened this issue Mar 4, 2024 · 6 comments
Closed

@placeholder vs @loading #54685

eluchsinger opened this issue Mar 4, 2024 · 6 comments
Labels
area: core Issues related to the framework runtime area: docs Related to the documentation core: defer Issues related to @defer blocks. P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: has PR
Milestone

Comments

@eluchsinger
Copy link
Contributor

Describe the problem that you experienced

Reading the @defer documentation, the two sub blocks @placeholder and @loading are mentioned.

But there is no guidance on when to use which one and what the differences are. Both blocks seem to do the same thing and accept the same parameters. A loading spinner can also be a placeholder.

How should each one of these sub blocks be used? Is this just a semantic difference?

Enter the URL of the topic with the problem

https://angular.io/guide/defer#blocks

Describe what you were looking for in the documentation

No response

Describe the actions that led you to experience the problem

No response

Describe what you want to experience that would fix the problem

Expand on when to use @loading vs @placeholder. There seems to be no difference in functionality.

Add a screenshot if that helps illustrate the problem

No response

If this problem caused an exception or error, please paste it here

No response

If the problem is browser-specific, please specify the device, OS, browser, and version

No response

Provide any additional information here in as much as detail as you can

No response

@JeanMeche
Copy link
Member

JeanMeche commented Mar 4, 2024

Hi,

Placeholder:

The @Placeholder is an optional block that declares content to show before the defer block is triggered.

Loading:

The @Loading block is an optional block that allows you to declare content that will be shown during the loading of any deferred dependencies.

The difference seams quite clear here. The loading block replaces the placeholder onces trigger has fired/loading has started.

@eluchsinger
Copy link
Contributor Author

Sorry - I must have missed that first paragraph. I agree that the sentence in the @placeholder sub block makes it quite clear. But the second sentence only makes sense after realizing that there are three states in a @defer block:

  1. Waiting: The @defer block has not been triggered; conditions not met. The content is not loading.
  2. Loading: The @defer is triggered (conditions are met). The deferred content is loading. The @placeholder block is now hidden and the @loading block is showing).
  3. Loaded/Ready: The deferred content is loaded and shown. Other sub blocks disappear.

@pkozlowski-opensource pkozlowski-opensource added area: core Issues related to the framework runtime core: defer Issues related to @defer blocks. area: docs Related to the documentation labels Mar 4, 2024
@ngbot ngbot bot added this to the needsTriage milestone Mar 4, 2024
@ducin
Copy link
Contributor

ducin commented Mar 7, 2024

IMO adding a simple sentence would help a lot:

The @loading block is an optional block that allows you to declare content that will be shown during the loading of any deferred dependencies. The @loading block replaces the @Placeholder block once loading has been triggered. For example, you could show a loading spinner. Similar to @placeholder, the dependencies of the @loading block are eagerly loaded.

@eluchsinger
Copy link
Contributor Author

I have created a PR for your change @ducin. I think it's a small enough change so that it's hopefully not complicated to merge it 👍 . Let's see what happens!

@bencodezen bencodezen added the P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent label Mar 13, 2024
@ngbot ngbot bot modified the milestones: needsTriage, Backlog Mar 13, 2024
@AndrewKushnir
Copy link
Contributor

Closing this issue, since PR #54779 was merged.

@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 May 5, 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 area: docs Related to the documentation core: defer Issues related to @defer blocks. P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent state: has PR
Projects
None yet
Development

No branches or pull requests

6 participants