How to get previous value before interactions?

For example,

for one component (such as a bool to indicate visibility of a UI component), the value could be T or F.

When previous value is T, current value is T, a specific action is needed.
When previous value is F, current value is T, another action is needed.

Now, in the callback function, we can only know the current value.

@irecsys here an example how to to this: