You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for RelayCommand that returns a ValueTask.
Currently, the SG works only for the RelayCommand that returns a Task.
In certain scenarios, returning a ValueTask instead of a Task can be more efficient. For instance, a command that returns data from the cache, if available, and initiates a network call only in the event of a cache miss.
API breakdown
// Works currently[RelayCommand]privateTaskDoWork1Async()=>Task.CompletedTask;// To be implemented[RelayCommand]privateValueTaskDoWork2Async()=>ValueTask.CompletedTask;
Usage example
Similar to Task, the method returns ValueTask if the hot path is synchronous. Design decision.
I guess this could be done by storing and checking if the return type is a Task or a ValueTask, then later use the return type's value in the generated source-code?
Overview
Add support for RelayCommand that returns a ValueTask.
Currently, the SG works only for the RelayCommand that returns a Task.
In certain scenarios, returning a ValueTask instead of a Task can be more efficient. For instance, a command that returns data from the cache, if available, and initiates a network call only in the event of a cache miss.
API breakdown
Usage example
Similar to Task, the method returns ValueTask if the hot path is synchronous. Design decision.
Breaking change?
No
Alternatives
Manually create the Command infra.
Additional context
https://devblogs.microsoft.com/dotnet/understanding-the-whys-whats-and-whens-of-valuetask/
Help us help you
No, just wanted to propose this
The text was updated successfully, but these errors were encountered: