-
Notifications
You must be signed in to change notification settings - Fork 26.2k
Alias afterRender
to afterEachRender
#54825
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
Comments
I'd go with afterEachRefresh -> as Angular refreshes bindings and doesn't re-render. |
I always wondered why It's very confusing to distinguish between the AfterNextRender and AfterRender, my colleague keeps forgetting what is what - with quite big impact. |
true, same here |
Yes, it is very confuse, I think there is an action we doing after something, like an action layer on other layer, so we can use
|
Same problem here... Progressively replacing It's honestly a bit of a mess with the current names... combining: speed, IDE autocomplete capabilities, right function call is almost an NP-Hard problem! 😅 IMHO, too much error prone! |
The team agrees that the name could be improved. The change will likely land as part of the stabilisation process of these 2 functions. |
We decided to removed |
@JeanMeche say: still Just an idea: how about a migration renaming In the end, they are still in dev-preview! |
@mauriziocescon we can debate names but we shouldn't use anything that suggests "first" / "initial" - the |
Well, I understand... just saying it can be easily misunderstood or not understood at all (especially if you're coming from the But ok, it can be a point for the future as well... maybe following something like:
|
@mauriziocescon I think there is a misunderstanding here - |
+1, was about to answer you on twitter.
This is done for a reason, it's mainly a DOM hook you want to call once the DOM has stabilized |
Ok, I might be completely off then... sorry for the confusion! Let me explain how I (rarely) use it then: as an OnInit that runs only on the client without phases! // onInit called client-side and potentially doing DOM manipulation
private readonly domReady = afterNextRender(() => this.someInit()); I must admit I've never took a deep look at the phases part (flagged it as too complex in my mind). My bad! I wonder: would you be so kind to elaborate on what I'm doing wrong? Or correct my mental model regarding it? 🙏 |
If it's for DOM manipulation it's fine. The phases are here to prevent multiple reflow by ordering the multiple after render callbacks. earlyRead > Write > ReadWrite > Read. |
Yeah... that part was more or less clear (again haven't checked all the details... and I'm not a real expert of reflows)! What I wonder is: maybe designed with a different purpose in mind... but isn't Confused now... |
|
Say: what What is not clear to me is the relationship between
|
Imagine you want to read the size of your component, but that size directly depends on the size of a neighbouring component (like with flex ratios). |
Ok, I checked the phases part in the doc and indeed it's clear the reason of the name now! Thanks! Say: maybe it's just me, but I have the feeling it targets sort of lib / advance cases... rather than more common ones in pure DEV land "hey I need to do some basic DOM manipulation (elRef) and I want it to be safe while using SSR (or even just future proof)". The fact all phases are optional doesn't help either (yeah... more APIs then). Anyway: thanks! |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Which @angular/* package(s) are relevant/related to the feature request?
@angular/core
Description
@angular/core
afterRender
andafterNextRender
are great however it is too easy to miss the distinction during a peer review and this can have a big effect on performance.Is it possible to alias
afterRender
toafterEachRender
or similar (I understand that it is too late to change names now).The new name would be clear that the code attached will run multiple times (as opposed to once only if using afterNextRender).
Proposed solution
Rename
afterRender
toafterEachRender
Alternatives considered
Currently if used I asked the devs to
import { afterRender as afterEachRender }
. We could add a lint task to ensure this is done.BTW I don't get a chance to say this elsewhere - so will say it here - thank you for all your work. Every change your team makes is so positive.
The text was updated successfully, but these errors were encountered: