Add a observer that prints the state change