Can you use code to detect when a variable changes?

Well basically what I want to do is have my code figure out that a variable has changed value and then call a function to store that value in my class.

I have a component with a text box in it that displays a value gotten from either typing in the box or moving a slider. I then need the last value (where they stop sliding or typing) to be stored in my class.

Is there any other way than trying to use the onChange of the text box?

Thanks in advance