@page "/now" @implements IDisposable @inject IJSRuntime JS @inject State State Feel free to stroll through the now.garden and take a look at what people are up to.
@if (garden != null) { foreach (NowData now in garden) {
} }
@code { private List? garden; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); if (garden == null || garden.Count == 0) garden = await State.GetNowGarden(); State.PropertyChanged += StateChanged; State.CanRefresh = true; await InvokeAsync(StateHasChanged); await JS.InvokeVoidAsync("removeElementById", "now-loading"); } private async void StateChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) { garden = await State.GetNowGarden(true); State.IsRefreshing = false; } } public void Dispose() { State.PropertyChanged -= StateChanged; State.CanRefresh = false; } }