Implement StateMachine.stateChanged.