public sealed class AsyncComputed<TRequest, T>A value derived asynchronously, re-derived when what it was asked for changes.
No guide page documents this yet — the page shows what the code says about itself.
Remarks
Split in two on purpose. The request is a synchronous function of signals, and it is what dependency tracking sees; the load is asynchronous and is tracked by nothing. That split is not decoration — tracking stops at the first await, because the ambient consumer is thread-local and the continuation is on another thread, so an async function that read signals after awaiting would silently record half its dependencies. Making the tracked half separate and synchronous means the compiler enforces what the graph can actually observe.
A new request cancels the one in flight. Results are handed back through Post, so they are applied on the owning thread at a defined point in the frame — the same guarantee everything else in this assembly makes, and the reason nothing here needs a lock.
Fields and properties (2)
public AsyncValue<T> ValueThe current state of the derivation.
public bool IsDisposedWhether Dispose has been called.
Methods (3)
public AsyncComputed(Func<TRequest> request, Func<TRequest, CancellationToken, Task<T>> load, EffectScheduler? scheduler = null)Creates an asynchronous derivation and queues its first run.
public AsyncValue<T> Peek()The current value without recording a dependency.
public void Dispose()Cancels anything in flight and stops re-deriving.
Used by (1)
- AsyncComputedTestsVixen.Ui.Reactive.Tests