Just create a loop that checks its current value against its previous value, if it isnt equal, call the function.