title: Operations With Android LiveData in EditText?
body: <p>I have 3 editext and I have to multiply the numbers written in the first two, and make the result appear live on the third using Android Livedata.</p>
  <pre><code>viewModel.num1.observe(this,
      Observer { newNum1-&gt; binding.ediText1.text = newNum1.toString() }
  
  viewModel.num2.observe(this,
      Observer { newNum2-&gt; binding.ediText2.text = newNum2.toString() }
  
  viewModel.num3.observe(this,
      Observer { newNum3-&gt; binding.ediText3.text = newNum3.toString() }
  </code></pre>
  <p>I tried something like this, with 2 MutableLiveData and one MediatorLivedata, but i did something wrong because it didn't update live the third EditText. Could someone help me?</p>
  <pre><code>class MyViewModel : ViewModel() {
      private var num1 = MutableLiveData&lt;Int&gt;();
      private var num2 = MutableLiveData&lt;Double&gt;();
      private var mun3 = MediatorLiveData&lt;Double&gt;();
  
      num3.addSource(num1, this::onChanged);
      num3.addSource(num2, this::onChanged);
    
      
      private fun onChanged(x : Double) {
          var a = num1.value
          var b = num2.value
  
          if (a== null)
              a= 0;
          if (b== null)
              b= 0.0;
          
          num3.setValue(a * b);
      }
  }
  </code></pre>
  <p>I'm using Kotlin but i accept any kind of code, even in java.</p>
  <p>Thank you for your patience and help!</p>
  <p>Best regards, Mark.</p>