Skip to content

ConditionalPeriodicTrigger

A trigger that checks an app-specific condition every period and triggers when it is met.

Note that the triggerCondition is a ConditionalEvaluator function, which cannot be serialized to/from JSON. Thus, even though this trigger can be de/serialized from/to JSON, its triggerCondition cannot. This implies that this function cannot be retrieved as part of a StudyProtocol from a DeploymentService since it relies on specifying a Dart-specific function as the ConditionalEvaluator methods. Hence, this trigger is mostly useful when creating a StudyProtocol directly in the app using Dart code.

Inheritance
Annotations

Constructors

ConditionalPeriodicTrigger.fromJson

ConditionalPeriodicTrigger.fromJson(
  1. Map<String, dynamic> json
)

ConditionalPeriodicTrigger

ConditionalPeriodicTrigger({
  1. required Duration period,
  2. ConditionalEvaluator? triggerCondition,
})

Creates a ConditionalPeriodicTrigger.

Properties

fromJsonFunction

Function get fromJsonFunction
override

The function which can convert a JSON string to an object of this type.

period

Duration period
getter/setter pair

How often to check the triggerCondition. Also checked once on resume.

triggerCondition

  1. @JsonKey(includeFromJson: false, includeToJson: false)
ConditionalEvaluator? triggerCondition
getter/setter pair

The function that decides whether to trigger.

If null, this trigger never triggers.

Methods

toJson

Map<String, dynamic> toJson()
override

Return a JSON encoding of this object.