onResume method

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

Called by resume. Returns true if successfully resumed.

If false, the executor moves to ExecutorState.PausedButShouldBeResumed.

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;
  }

  if (configuration?.elapsedTime == null) {
    warning(
      '$runtimeType - This ElapsedTimeTrigger does not have a elapsedTime specified. Cannot execute this trigger.',
    );
    return false;
  }

  int delay =
      configuration!.elapsedTime!.inMilliseconds -
      (DateTime.now().millisecondsSinceEpoch - (deployment?.deployed.millisecondsSinceEpoch ?? 0));

  if (delay > 0) {
    timer = Timer(Duration(milliseconds: delay), () => onTrigger());
  } else {
    warning('$runtimeType - the trigger time is in the past and should have happened already.');
    return false;
  }

  return true;
}