Created
March 21, 2021 11:41
-
-
Save zHaytam/60636536895c681a8f9517e490c80b78 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Task IHandleEvent.HandleEventAsync(EventCallbackWorkItem callback, object? arg) | |
{ | |
var task = callback.InvokeAsync(arg); | |
var shouldAwaitTask = task.Status != TaskStatus.RanToCompletion && | |
task.Status != TaskStatus.Canceled; | |
// After each event, we synchronously re-render (unless !ShouldRender()) | |
// This just saves the developer the trouble of putting "StateHasChanged();" | |
// at the end of every event callback. | |
StateHasChanged(); | |
return shouldAwaitTask ? | |
CallStateHasChangedOnAsyncCompletion(task) : | |
Task.CompletedTask; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment