onResume method

  1. @override
Future<bool> onResume()
override

Callback when this executor is resumed. Returns true if successfully resumed, false otherwise.

Implementation

@override
Future<bool> onResume() async {
  Duration? interval = samplingConfiguration?.interval;
  if (interval != null) {
    // create a recurrent timer that gets the data point every [frequency].
    timer = Timer.periodic(interval, (Timer t) async {
      try {
        Datum? datum = await getDatum();
        if (datum != null) addData(datum);
      } catch (error) {
        addError(error);
      }
    });
  } else {
    warning(
        '$runtimeType - no valid interval found in sampling configuration: $samplingConfiguration. '
        'Is a valid IntervalSamplingConfiguration provided?');
    return false;
  }
  return true;
}