Equivalent of ObserveOnDispatcher in Blazor

Viewed 149

In Blazor, there is no single UI thread and as far as I know no dispatcher. There is ComponentBase.InvokeAsync(..) however:

protected Task InvokeAsync(Action workItem);
protected Task InvokeAsync(Func<Task> workItem);

How do I switch from non-ui thread to UI thread?

IObservable<int> source ...
source.Throttle(100) // will continue on non UI thread
  .ObserveOnComponent() // how do I write this?
  .ObserveOn(this.InvokeAsync) // or this?
  .Do(this.StateHasChanged); // something that requires UI thread
  .Subscribe();
0 Answers
Related