select<T> method
Create a derived pod, that transforms a pod's value using the given
function cb
.
Only rebuilds when the selected value changes.
Implementation
PodFuture<P, AsyncValue<T>> select<T>(
T Function(V value) cb,
) =>
PodFuture(
future,
(ref, future) {
final value = ref.watch(this).transform(cb);
if (value.valueOrNull != null) {
// ignore: null_check_on_nullable_type_parameter
return AsyncValue.data(value.valueOrNull!);
}
final prev = ref.self();
if (prev is AsyncValue<T>) {
return prev;
}
return value;
},
);