I'm trying to get my child components to subscribe to a notification event by invoking it inside my service. How do I subscribe to it? I'm getting an error stating I cannot implicitly convert type System.Threading.Tasks.Task to System.Func<System.Threading.Tasks.Task>.
Here's my service implementation:
public event Func<Task> Notify;Then I have a child method to call inside my service:
public async Task Subscribe(string value){ ... await Notify!.Invoke();}Then in my child component, I'm trying to subscribe like so:
private async Task OnNotify(){ await InvokeAsync(() =>{ ... StateHasChanged(); }); }Inside my OnInitializedAsync() method is where I'm trying to subscribe but I get the above error:
protected override Task OnInitializedAsync(){ Notifier.Notify += OnNotify(); return base.OnInitializedAsync();}How do I subscribe to an asynchronous event when it returns Func<Task>?