@page "/ephemeral" @implements IDisposable @inject IJSRuntime JS @inject State State Eph.emer.al is a place for fleeting thoughts. Everything on this page will disappear after a while.
@if (messages != null) { foreach (MarkupString message in messages) {
@message
} }
@code { private List? messages; protected override async Task OnInitializedAsync() { await base.OnInitializedAsync(); if (messages == null || messages.Count == 0) messages = await State.GetEphemeralMessages(); State.PropertyChanged += StateChanged; State.CanRefresh = true; await InvokeAsync(StateHasChanged); await JS.InvokeVoidAsync("removeElementById", "ephemeral-loading"); } private async void StateChanged(object? sender, PropertyChangedEventArgs e) { if (e.PropertyName == nameof(State.IsRefreshing) && State.IsRefreshing) { messages = await State.GetEphemeralMessages(true); State.IsRefreshing = false; } } public void Dispose() { State.PropertyChanged -= StateChanged; State.CanRefresh = false; } }