select<V> 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<Pod<AsyncValue<T>>, AsyncValue<V>> select<V>(
V Function(T value) cb,
) =>
PodFuture(
this,
(ref, parent) {
final value = ref.watch(parent).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<V>) {
return prev;
}
return value;
},
);