onResume method
Callback when this executor is resumed. Returns true if successfully resumed, false otherwise.
Implementation
@override
Future<bool> onResume() async {
Duration? interval = samplingConfiguration?.interval;
Duration? duration = samplingConfiguration?.duration;
if (interval != null && duration != null) {
timer = Timer.periodic(interval, (Timer t) {
onSamplingStart();
subscription = bufferingStream.listen(onSamplingData,
onError: onError, onDone: onDone);
Timer(duration, () async {
await subscription?.cancel();
onSamplingEnd();
try {
Datum? datum = await getDatum();
if (datum != null) addData(datum);
} catch (error) {
addError(error);
}
});
});
} else {
warning(
'$runtimeType - no valid interval and duration found in sampling configuration: $samplingConfiguration. '
'Is a valid PeriodicSamplingConfiguration provided?');
return false;
}
return true;
}