-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Closed
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedaffected-mostThis issue impacts most of the customersThis issue impacts most of the customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-component-modelAny feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)feature-razor.languageseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Description
https://docs.microsoft.com/en-us/aspnet/core/blazor/data-binding?view=aspnetcore-3.1
Data-binding takes place with the following syntax:
<input @bind="CurrentValue" />
@code {
private string CurrentValue { get; set; }
}
this is equivalent of
<input value="@CurrentValue"
@onchange="@((ChangeEventArgs __e) => CurrentValue =
__e.Value.ToString())" />
@code {
private string CurrentValue { get; set; }
}
I can use the setter
of the bound property to handle some extra logic
[Parameter]
public EventCallback<string> Callback { get; set; }
private string _value;
private string CurrentValue
{
get => _value;
set {
_value = value;
// extra logic
// await Callback.InvokeAsync(value);
// above does not work, we are in the 'sync'-world
}
}
I find myself starting with this pattern and then getting stuck because I need to call something async. I rewrite the thing to handle the events myself, but it feels a bit... not finished. It becomes a real pain if you have made a reusable component and you need to refactor a lot to make it work with the async call.
Can we introduce a convention to allow async calls with two way binding?
Gaulomatic, Timovzl, chrdlx, rodion-m, ThomasBleijendaal and 4 moreTLA020
Metadata
Metadata
Assignees
Labels
✔️ Resolution: DuplicateResolved as a duplicate of another issueResolved as a duplicate of another issueStatus: Resolvedaffected-mostThis issue impacts most of the customersThis issue impacts most of the customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsenhancementThis issue represents an ask for new feature or an enhancement to an existing oneThis issue represents an ask for new feature or an enhancement to an existing onefeature-blazor-component-modelAny feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)Any feature that affects the component model for Blazor (Parameters, Rendering, Lifecycle, etc)feature-razor.languageseverity-minorThis label is used by an internal toolThis label is used by an internal tool