onResume method
Callback when this executor is resumed. Returns true if successfully resumed, false otherwise.
Implementation
@override
Future<bool> onResume() async {
// Fast out if no deployment.
if (deployment == null) return false;
SmartphoneStudy? study = SmartPhoneClientManager().getStudy(
deployment!.studyDeploymentId,
deployment!.deviceRoleName,
);
_subscription ??= SmartPhoneClientManager()
.getStudyController(study!)
?.measurementsByType(configuration!.measureType)
.distinct()
.listen((measurement) {
if (configuration?.triggerCondition == null) {
// always trigger if the condition is null
onTrigger();
} else
// check the trigger condition
if (measurement.data.equivalentTo(configuration!.triggerCondition!)) {
onTrigger();
}
});
return true;
}