code: 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);
      }
    }
  }
docs: Handle connection state change.
  
  @param {LeaderElection} election
  @param {ConnectionState} state