@implements IDisposable;
@inject IMemoryTesterService MemoryTesterService;
@if (entities != null && questions != null)
{
@foreach (var entityMemory in entities)
{
}
}
Refresh
Submit
@code {
private List entities = null!;
private List questions = null!;
protected override void OnInitialized()
{
MemoryTesterService.Subscribe(OnMemoryEvent);
MemoryTesterService.GenerateQuiz();
}
void IDisposable.Dispose()
{
MemoryTesterService.Unsubscribe(OnMemoryEvent);
}
void OnMemoryEvent(MemoryTesterEvent memoryTesterEvent)
{
if (memoryTesterEvent == MemoryTesterEvent.OnVerify)
{
StateHasChanged();
}
if (memoryTesterEvent == MemoryTesterEvent.OnRefresh)
{
entities = MemoryTesterService.GetEntities();
questions = MemoryTesterService.GetQuestions();
StateHasChanged();
}
}
void OnSubmitQuiz(EventArgs eventArgs)
{
MemoryTesterService.Verify();
}
void OnRefreshQuiz(EventArgs eventArgs)
{
MemoryTesterService.GenerateQuiz();
}
}