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

Something seems off with the lifecycle of the controller and view during initialization #4

Open
4deeptech opened this issue Jul 25, 2022 · 0 comments

Comments

@4deeptech
Copy link

4deeptech commented Jul 25, 2022

If you change line 21 to bypass having to have a local variable for _forecasts to the following:

View.Forecasts = await Http.GetFromJsonAsync<WeatherForecast[]>("sample-data/weather.json");

Then View is null and the page blows up.

Subsequently, if you create a bUnit test to exercise the FetchDataController, View is always(almost-timing) null in OnInitializedAsync.

I am guessing that the issue here is that the View does not get set until BuildRenderTree runs which happens after the OnInitialized/async calls are made. This also means the OnViewInitialized is called before the OnInitializedAsync completes.

Curious to see what the solution is for the situation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant