ComputedSignalMany<V> constructor
ComputedSignalMany<V> ({
- required Set<
BaseSignal> source, - required V transform(),
A read-only signal whose value is derived from a set of signals.
Use this when you need a computed/derived value from signals
that live in the same node, without the verbosity of
TransformBridgeSignal.
late final total = registerSignal(
ComputedSignalMany(
{products, anotherSignal, ...},
() => products.value.fold<double>(
0.0, (prev, e) => prev + e.price,
),
),
);
Implementation
ComputedSignalMany({required this.source, required this.transform})
: super(transform()) {
_subscription.addAll(
source
.map(
(s) => s.stream.listen((data) {
if (unsafeValue != value) {
unsafeValue = value;
controller.add(value);
}
}),
)
.toList(),
);
}