In this recipe, we are going to explore the usage of the Vetoable delegate offered by the standard library. Similar to the Observable, the Vetoable tracks the changes applied to the delegated property. However, the Vetoable delegate is able to refuse to update the delegated property if a predefined update condition is not met. We are going to declare a variable of the Int type and specify the update condition, allowing us to update the variable only if the absolute value of change is greater than or equal to 10.
Restricting property updates with the Vetoable delegate
How to do it...
- Let's start by defining an initial value for the temperature variable:
val initialValue = 1
- Define the update condition for the observed...