title: Get notified of variable change using PropertyChangeSupport(e.g. observable, delegate)
body: <p>I have this kind of issue I would like to listen to variable change.
  Lets take I have <code>var foo:Int = 10</code> initialized and in the code somewhere it changes its value to something else lets take <code>foo = 99</code> here is my code snippet in kotlin.</p>
  
  <pre><code>var foo:Int=10
  
  private val changeSupport: PropertyChangeSupport? = PropertyChangeSupport(foo)
  
  val observer = {
                      property: KProperty&lt;*&gt;,
                      oldValue: Int?,
                      newValue: Int? -&gt; changeSupport!!.firePropertyChange(property.name, oldValue, newValue)
                  }
  
   var oof: Int? by Delegates.observable(foo, observer)
   changeSupport!!.addPropertyChangeListener { event -&gt;
                      Log.d("loggg","Property [${event.propertyName}] changed " + "from [${event.oldValue}] to [${event.newValue}]")
                  }
  </code></pre>
  
  <p>So while somewhere in the code I write <code>foo = 99</code> I have to receive the Log. I tried a lot of stuff I followed this articles but no success.
  Am I missing something?</p>
  
  <p><a href="https://stackoverflow.com/questions/15433855/how-to-create-change-listener-for-variable">How to create change listener for variable?</a></p>
  
  <p><a href="http://kotlination.com/kotlin/kotlin-observable-property-delegated-property" rel="nofollow noreferrer">http://kotlination.com/kotlin/kotlin-observable-property-delegated-property</a>
  <a href="https://www.javalobby.org/java/forums/t19476.html" rel="nofollow noreferrer">https://www.javalobby.org/java/forums/t19476.html</a></p>