Why do anything on the 2nd call to OnInitializedAsync()? #55267
Unanswered
DavidThielen
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is a follow-on question to my question Why is OnInitializedAsync() called twice?
What I have been doing to date, based on Microsoft's guidance that everything should be requested in the pre-render call, is:
But thinking about it today, it strikes me that we want to call all initialization in the pre-render pass. And then do nothing on the second pass. Which would be the following:
Is there any downside to the above? I ask, because why have 2 passes if doing this meets the Microsoft guidance to get everything in the pre-render pass?
The flip approach to the above is to do:
But following that means all the slow initialization will be started a bit later. That will mean it will take longer to fully initialize the page. And as Microsoft's guidance implies that a slow pre-render initialization will not slow down the rendering of the page skeleton, I don't see any advantage to this approach.
I'm asking the above because either approach, that seems to me to be the fastest with no duplication of DB reads, means basically that I am reducing this down to a single pass of
OnInitializationAsync()
, ignoring the other pass. But the Blazor team is smart and I don't think they would give us 2 passes to no advantage.So what am I missing?
thanks - dave
Beta Was this translation helpful? Give feedback.
All reactions