tagChanged method

MBTriggerChangedStatus tagChanged(
  1. String tag,
  2. String? value
)

Function called when a tag changes its value. @param tag The tag that has changed. @param value The new value of the tag. @returns The new trigger status (unchanged, valid, invalid).

Implementation

MBTriggerChangedStatus tagChanged(
  String tag,
  String? value,
) {
  if (tag != this.tag) {
    return MBTriggerChangedStatus.unchanged;
  }
  String? newValue = value;
  if (tagChangeOperator == MBTagChangeOperator.equal) {
    if (newValue == this.value) {
      completionDate = DateTime.now();
      return MBTriggerChangedStatus.valid;
    } else {
      completionDate = null;
      return MBTriggerChangedStatus.invalid;
    }
  } else if (tagChangeOperator == MBTagChangeOperator.notEqual) {
    if (newValue != this.value) {
      completionDate = DateTime.now();
      return MBTriggerChangedStatus.valid;
    } else {
      completionDate = null;
      return MBTriggerChangedStatus.invalid;
    }
  }
  return MBTriggerChangedStatus.unchanged;
}