createComputedFrom<S, A> method
Async Computed is syntax sugar around FutureSignal.
Inspired by computedFrom from Angular NgExtension.
computedFrom takes a list of signals
and a callback
function to
compute the value of the signal every time one of the signals
changes.
final movieId = signal('id');
late final movie = computedFrom(args, ([movieId]) => fetchMovie(args.first));
Since all dependencies are passed in as arguments there is no need to worry about calling the signals before any async gaps with await.
Implementation
FutureSignal<S> createComputedFrom<S, A>(
List<ReadonlySignal<A>> signals,
Future<S> Function(List<A> args) fn, {
S? initialValue,
String? debugLabel,
bool lazy = true,
}) {
return _bindLocal(computedFrom<S, A>(
signals,
fn,
initialValue: initialValue,
debugLabel: debugLabel,
lazy: lazy,
));
}