ChildPod<TParent extends Object, TChild extends Object> constructor
ChildPod<TParent extends Object, TChild extends Object> ({
- required TPodsResponderFn<
TParent> responder, - required TValuesReducerFn<
TChild, TParent> reducer,
Implementation
ChildPod({
required TPodsResponderFn<TParent> responder,
required TValuesReducerFn<TChild, TParent> reducer,
}) : _reducer = reducer,
_responder = responder {
// Materialise responder output to a List so a `sync*` generator (or
// any other one-shot iterable) is fully consumed exactly once.
// [_initializeParents] and the reducer call both iterate; without
// this snapshot, a generator-style responder would yield nothing on
// the second walk and parent subscriptions would silently desync.
final initial = responder().toList();
_parents = initial;
value = reducer(initial.map((p) => p.value).toList());
_initializeParents(initial);
}