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 {
  if (deployment?.deployed == null) {
    warning(
        '$runtimeType - this deployment does not have a start time. Cannot execute this trigger.');
    return false;
  } else {
    int delay = configuration!.elapsedTime.inMilliseconds -
        (DateTime.now().millisecondsSinceEpoch -
            deployment!.deployed!.millisecondsSinceEpoch);

    if (delay > 0) {
      Timer(Duration(milliseconds: delay), () => super.onResume());
    } else {
      warning(
          '$runtimeType - delay is negative, i.e. the trigger time is in the past and should have happend already.');
    }
  }

  return true;
}