Applied an observer pattern to notify state changes.