title: More fun with Kotlin delegates
body: <p>If you know Google's experimental Android Architecture Components, you probably know <code>MutableLiveData</code>. Trying to make it a bit more fun to use I came with:</p>
  
  <pre><code>class KotlinLiveData&lt;T&gt;(val default: T) {
      val data = MutableLiveData&lt;T&gt;()
  
      operator fun getValue(thisRef: Any?, property: KProperty&lt;*&gt;):T {
          return data.value ?: default
      }
  
      operator fun setValue(thisRef: Any?, property: KProperty&lt;*&gt;, value:T) {
          if (Looper.myLooper() == Looper.getMainLooper()) {
              data.value = value
          } else {
              data.postValue(value)
          }
      }
  }
  </code></pre>
  
  <p>And then I can:</p>
  
  <pre><code>var name : String by KotlinLiveData("not given")
  name = "Chrzęszczybrzęczykiewicz"
  </code></pre>
  
  <p>But alas - that makes <code>data</code> which is needed i.e. to register <code>Observer</code> inaccessible:</p>
  
  <pre><code>name.data.observe(this, nameObserver) // won't work :(
  </code></pre>
  
  <p>Any idea if I can get it somehow?</p>