title: MVVM MediatorLiveData observer onchanged called multiple times
body: <p>I am using MVVM + LiveData + Dagger 2.11 on my app.On SignInFragment click on a textview send request to server and show respopnse on snackbar. It works fine on first time click of textview.If I click again,it sends request(inbetween shows snackbar response message here) and ViewModel MediatorLiveData observer onChanged method called muliple times.Is it default behaviour of MediatorLiveData? </p>
  
  <p><strong>SignInViewModel.java</strong></p>
  
  <pre><code>public class SignInViewModel extends AndroidViewModel {
  
      @Inject
      MediatorLiveData mediatorLiveData;
  
      @Inject
      SnackbarMessage mSnackbarTextLiveData = new SnackbarMessage();
  
      @Inject
      public SignInViewModel(Application application,SignInRepository signInRepository) {
          super(application);
          this.signInRepository = signInRepository;
      }
  
      public MediatorLiveData&lt;ResendActivationCodeResponse&gt; resendActivationCode(final String phoneNumber, final String countryCode) {
          final MutableLiveData&lt;NetworkResponse&gt; connectViaPhoneResponseMutableLiveData = signInRepository.resendActivationCode(phoneNumber, countryCode);
  
          mediatorLiveData.addSource(connectViaPhoneResponseMutableLiveData, new NetworkResponseObserver() {
              @Override
              public void onSuccess(Object data) {
                  mediatorLiveData.setValue(data);
              }
  
              @Override
              public void onBadRequest(Object data, String errorMessage) {
                  mSnackbarTextLiveData.setValue(errorMessage);
              }
  
              @Override
              public void onUnAuthorisedError(Object data) {
                  mSnackbarTextLiveData.setValue(data.toString());
              }
  
              @Override
              public void onFailure(Object data, String errorMessage) {
                  mSnackbarTextLiveData.setValue(errorMessage);
              }
  
              @Override
              public void onNoNetworkAvailable(Object data, String errorMessage) {
                  mSnackbarTextLiveData.setValue(data.toString());
              }
  
              @Override
              public void onLoading(Object data) {
  
              }
          });
          return mediatorLiveData;
      }
  }
  </code></pre>
  
  <p><strong>SignInFragment.java</strong></p>
  
  <pre><code>@Override
      public void onActivityCreated(@Nullable Bundle savedInstanceState) {
          super.onActivityCreated(savedInstanceState);
          mSignInViewModel = ViewModelProviders.of(mActivity, mViewModelFactory).get(SignInViewModel.class);
          setupSnackbar();
      }
  
      private void setupSnackbar() {
          mSignInViewModel.getSnackbarMessage().observe(this, new SnackbarMessage.SnackbarObserver() {
              @Override
              public void onNewMessage(String snackbarMessage) {
                  ActivityUtils.showSnackbar(getView(), snackbarMessage);
              }
          });
      }
  
      @OnClick(R.id.resend_activation_code_textview)
      public void reSendActivationCode() {
          showProgress(true);
  
          final MediatorLiveData&lt;ResendActivationCodeResponse&gt; resendActivationCodeResponseMediatorLiveData = mSignInViewModel.resendActivationCode(mPhoneNumber, mCountryCode);
  
  
          Observer&lt;ResendActivationCodeResponse&gt; resendActivationCodeResponseObserver = new Observer&lt;ResendActivationCodeResponse&gt;() {
  
              @Override
              public void onChanged(@Nullable ResendActivationCodeResponse resendActivationCodeResponse) {
                  if (resendActivationCodeResponse != null) {
                      showProgress(false);
                      ActivityUtils.showSnackbar(getView(), activationCodeResentMessage);
                      //resendActivationCodeResponseMediatorLiveData.removeObserver(this);
                  }
              }
          };
  
  
          resendActivationCodeResponseMediatorLiveData.observe(PhoneNumberActivationFragment.this, resendActivationCodeResponseObserver);
      }
  </code></pre>