reduce3Pods<T, A, B, C> function

ChildPod<dynamic, T> reduce3Pods<T, A, B, C>(
  1. Pods3<A, B, C> instances,
  2. T reducer(
    1. Pods3<A, B, C> values
    ),
  3. (A?, B?, C?) updateParents(
    1. T childValue
    )?
)

Reduces a tuple 3 Pod - instances to a single ChildPod instance via reducer. Optionally provide updateParents to define how parent Pods should be updated when this Pod changes.

Implementation

ChildPod<dynamic, T> reduce3Pods<T, A, B, C>(
  Pods3<A, B, C> instances,
  T Function(Pods3<A, B, C> values) reducer,
  (A?, B?, C?) Function(T childValue)? updateParents,
) {
  return ChildPod<dynamic, T>(
    parents: instances.pods.nonNulls,
    reducer: (_) => reducer(instances),
    updateParents: updateParents != null
        ? (e) {
            final temp = updateParents(e);
            return [temp.$1, temp.$2, temp.$3];
          }
        : null,
  );
}