title: Observer on LiveData in RecyclerView - Kolin
body: <p>how can I implement LiveData Observer in the Recycler View? I have a global var `someDataChanged' that gets updated from another Fragment. Any help would be greatly appreciated!</p>
  <pre><code>class GlobalActivity {
  
      companion object {
          someDataChanged = MutableLiveData&lt;Int&gt;()
      }
  }
  </code></pre>
  <p>Then in the Adapter.kt for the RecyclerView I need to listen if the <code>someDataChanged</code>. I have the following code:</p>
  <pre><code>Adapter.kt
  var mRecyclerView: RecyclerView? = null
  
  class MainAdapter(val myResponse: MyResponse): RecyclerView.Adapter&lt;CustomViewHolder&gt;(){
  
      
      override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): CustomViewHolder {
      
          //Error: this is not recognized.  
          GlobalActivity.someDataChanged`.observe(this, Observer{
              println(&quot;Data Changed&quot;)
          })
  
          val layoutInflater = LayoutInflater.from(parent?.context)
          val cellForRow = layoutInflater.inflate(R.layout.my_custom_cell, parent,false)
          return CustomViewHolder(cellForRow)
  
      }
  
      override fun onBindViewHolder(holder: CustomViewHolder, position: Int) {
   
          //some code
          class CustomViewHolder(val view: View, var myPass: Passes? = null): RecyclerView.ViewHolder(view){
  
          }
      }
  }
  </code></pre>