具有函数async Task FilesReadyForContent(IMatFileUploadEntry[] files)
{
string base64Audio; // variable defined outside the function to update DOM
bool loadingAudio; // defined outside
try
{
file = files.FirstOrDefault();
if (file == null)
{
base64Audio = "Error! Could not load file";
}
else
{
using (MemoryStream ms = new MemoryStream())
{
loadingAudio = true;
await InvokeAsync(() => this.StateHasChanged());
await file.WriteToStreamAsync(ms);
base64Audio = System.Convert.ToBase64String(ms.ToArray());
loadingAudio = false;
await InvokeAsync(() => this.StateHasChanged());
}
}
}
catch (Exception ex)
{
base64Audio = $"Error! Exception:\r\n{ex.Message}\r\n{ex.StackTrace}";
}
finally
{
await InvokeAsync(() => { this.StateHasChanged(); });
}
}
,该函数返回一个myFunc
,是否可以将其转换为Mono函数,其行为就像从内部从Mono中提取值一样?
Mono
请考虑如何编写函数Function<A, Mono<B>> myFunc = createMyFunction(....);
/* how this decorator works? */
Mono<Function<A, B> myFuncMono = magicDecorator(myFunc);
。
更新:
如果这看起来不可能,那么让我们考虑一个更简单的问题。
如何将magicDecorator
转换为List<Mono<String>>
?
实际上,我试图了解一个参数的“反应性”是否可以传播到更高的位置:即从列表元素到列表本身,从函数结果到函数本身。