lib/LeaderElection.js
function handleStateChange(election, state) {
  if (state === ConnectionState.RECONNECTED) {
    reset(election, afterReset);
  }
  else if (state === ConnectionState.SUSPENDED ||
    state === ConnectionState.LOST) {
    setLeadership(election, false);
  }

  function afterReset(err) {
    if (err) {
      election.emit('error', err);
      setLeadership(election, false);
    }
  }
}
function handleStateChange(election, state) {
  if (state === ConnectionState.RECONNECTED) {
    reset(election, afterReset);
  }
  else if (state === ConnectionState.SUSPENDED ||
    state === ConnectionState.LOST) {
    setLeadership(election, false);
  }

  function afterReset(err) {
    if (err) {
      election.emit('error', err);
      setLeadership(election, false);
    }
  }
}
function handleStateChange ( election , state ) { if ( state === ConnectionState . RECONNECTED ) { reset ( election , afterReset ) ; } else if ( state === ConnectionState . SUSPENDED || state === ConnectionState . LOST ) { setLeadership ( election , false ) ; } function afterReset ( err ) { if ( err ) { election . emit ( 'error' , err ) ; setLeadership ( election , false ) ; } } }
Handle connection state change.

@param {LeaderElection} election
@param {ConnectionState} state
Handle connection state change .