track<T> method
T?
track<T>(
- Element? element,
- ElementValueGetter<
T> ? elementValueGetter, - OnElementTrackValueEvent<
T> ? onTrackValueEvent, { - bool periodicTracking = false,
Tracks element
using elementValueGetter
to catch the value.
element
The element to track.
elementValueGetter
The value getter.
onTrackValueEvent
Callback to call when value changes.
periodicTracking
If true
this tracking will continue after first event.
Implementation
T? track<T>(Element? element, ElementValueGetter<T>? elementValueGetter,
OnElementTrackValueEvent<T>? onTrackValueEvent,
{bool periodicTracking = false}) {
if (element == null ||
elementValueGetter == null ||
onTrackValueEvent == null) {
return null;
}
if (_elements.containsKey(element)) return null;
var elementTrack = _ElementTrack(
this, element, elementValueGetter, periodicTracking, onTrackValueEvent);
_elements[element] = elementTrack;
var initialValue = elementTrack._initialize();
_scheduleCheck();
return initialValue;
}