@page "/feed" @implements IDisposable @inject IJSRuntime JS @inject State State A feed of all the statuses and pics of the people you follow. @if (feed != null) foreach (StatusOrPic item in feed) { if (item.IsStatus) { } else if (item.IsPic) { } } @code { private IOrderedEnumerable? feed; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); if (feed == null || feed.Count() == 0) feed = await State.GetFeed(); State.PropertyChanged += StateChanged; State.CanRefresh = true; await InvokeAsync(StateHasChanged); await JS.InvokeVoidAsync("removeElementById", "feedLoading"); } private async void StateChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) { using (State.GetRefreshToken()) { feed = await State.GetFeed(true); await InvokeAsync(StateHasChanged); } } } public void Dispose() { State.PropertyChanged -= StateChanged; State.CanRefresh = false; } }