First change the state, then dispatch the triggered event.