AsyncComputed<T> constructor
AsyncComputed<T> (})
Creates an instance of AsyncComputed with the given async function.
getValue
: The function that fetches the computed value asynchronously.defaultValue
: A default value before the async computation completes.beforeUpdate
: A function to set a temporary value before computation.notifyBeforeUpdate
: If true, notifies listeners whenbeforeUpdate
sets a new value.onError
: Callback function for handling errors during async computation.immediate
: If true, starts the async computation immediately upon creation.
Implementation
AsyncComputed(this._getValue,
{T? defaultValue,
this.beforeUpdate,
this.notifyBeforeUpdate = true,
this.onError,
immediate = false}) {
_value = defaultValue;
if (immediate) _runDry();
}