ReducerPod<T extends Object> class
base
A Pod that listens to changes to existing Pods returned by the responder. When any of these returned Pods update, it recalculates its value using the reducer function, then calls the responder again to refresh Pods to listen to. This recursive behaviour ensures that the Pod continuously listens to new changes from any updated Pods.
T
is the type of this Pod and the value produced by the reducer
function.
Note that when this pod disposes via dispose, it will not dispose the Pods provided by responder. Explicit disposal is needed.
- Inheritance
-
- Object
- WeakChangeNotifier
- DisposablePod<
T> - PodNotifier<
T> - ReducerPod
- Mixed-in types
-
- GenericPod<
T>
- GenericPod<
- Available extensions
Constructors
-
ReducerPod.new({required Iterable<
Option< responder(), required Option<ValueListenable< >Object> >T> reducer(List<Option< values)})Object> > -
ReducerPod.single(Option<
ValueListenable< responder())T> > -
factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
- isDisposed → bool
-
Whether this Pod has been disposed of or not.
no setterinherited
-
reducer
→ Option<
T> Function(List<Option< values)Object> > -
Reduces the values of the current Pods returned by responder to a
single value of type
T
, to update this Pod's value.final -
responder
→ Iterable<
Option< Function()ValueListenable< >Object> > -
Produces a list of Pods to listen to. This gets called recursively each
time any of the Pods in the returned list change.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- value ↔ T
-
The current value of the object. When the value changes, the callbacks
registered with addListener will be invoked.
getter/setter pairoverride
Methods
-
addListener(
VoidCallback listener) → void -
❌ Do not use this method directly. Use addStrongRefListener instead.
inherited
-
addSingleExecutionListener(
VoidCallback listener) → void -
Registers a listener that will be called only once when the object
notifies its listeners. After the listener is called, it is automatically
removed.
inherited
-
addStrongRefListener(
{required VoidCallback strongRefListener}) → void -
Register a closure to be called when the object notifies its listeners.
inherited
-
asChildPod<
TParent extends Object> () → ChildPod< TParent, T> -
Available on ValueListenable<
Casts the ValueListenable to a ChildPod.T> , provided by the ValueListenableExt extension -
asDisposablePod(
) → DisposablePod< T> -
Available on ValueListenable<
Casts the ValueListenable to a DisposablePod.T> , provided by the ValueListenableExt extension -
asGenericPod(
) → GenericPod< T> -
Available on ValueListenable<
Casts the ValueListenable to a GenericPod.T> , provided by the ValueListenableExt extension -
asProtectedPod(
) → ProtectedPod< T> -
Available on ValueListenable<
Casts the ValueListenable to a ProtectedPod.T> , provided by the ValueListenableExt extension -
asRootPod(
) → RootPod< T> -
Available on ValueListenable<
Casts the ValueListenable to a RootPod.T> , provided by the ValueListenableExt extension -
Available on ValueListenable<
Casts the ValueListenable to a SharedPod.T> , provided by the ValueListenableExt extension -
asValueListenable(
) → ValueListenable< T> -
Available on ValueListenable<
Returns the Pod as a ValueListenable.T> , provided by the ValueListenableExt extension -
cond(
bool test(T value)) → Resolvable< T> -
Returns the value of the Pod when the
test
returnstrue
.inherited -
dispose(
) → void -
Dipsoses this ValueListenable and sets isDisposed to
true
. Successive calls to this method will be ignored.override -
disposeChildren(
) → void -
Disposes and removes all children.
inherited
-
getValue(
) → T -
inherited
-
map<
B extends Object> (B reducer(T value)) → ChildPod< T, B> -
Maps
this
GenericPod to a new ChildPod using the specifiedreducer
.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
reduce<
C extends Object, O extends Object> (GenericPod< O> other, TReducerFn2<C, T, O> reducer) → ChildPod<Object, C> -
Reduces the current Pod and
other
into a single ChildPod.inherited -
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited