Skip to content

Commit 0dacc32

Browse files
authored
[Blazor] Update bind:set,after runtime apis (#44412)
* Runtime helpers update * Test updates * Fix build break
1 parent 01f48cd commit 0dacc32

File tree

4 files changed

+144
-154
lines changed

4 files changed

+144
-154
lines changed

src/Components/Components/src/CompilerServices/RuntimeHelpers.cs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,36 @@ public static EventCallback<T> CreateInferredEventCallback<T>(object receiver, E
7070
return EventCallback.Factory.Create<T>(receiver, callback);
7171
}
7272

73+
/// <summary>
74+
/// Not intended for use by application code.
75+
/// </summary>
76+
/// <param name="callback"></param>
77+
/// <param name="value"></param>
78+
/// <returns></returns>
79+
//
80+
// This method is used with `@bind-Value:set` to coerce the user provided expression to a Func<T, Task>.
81+
public static Func<T, Task> CreateInferredBindSetter<T>(Func<T, Task> callback, T value)
82+
{
83+
return callback;
84+
}
85+
86+
/// <summary>
87+
/// Not intended for use by application code.
88+
/// </summary>
89+
/// <param name="callback"></param>
90+
/// <param name="value"></param>
91+
/// <returns></returns>
92+
//
93+
// This method is used with `@bind-Value:set` to coerce the user provided expression to a Func<T, Task>.
94+
public static Func<T, Task> CreateInferredBindSetter<T>(Action<T?> callback, T value)
95+
{
96+
return (value) =>
97+
{
98+
callback(value);
99+
return Task.CompletedTask;
100+
};
101+
}
102+
73103
/// <summary>
74104
/// Not intended for use by application code.
75105
/// </summary>

0 commit comments

Comments
 (0)