title: Firebase realtime Android - how to handle callbacks that are called constantly
body: <p>I have the following code and as you can see I've added a delta time to avoid update the UI intensively.</p>
  <p>How can I solve this problem in a fancy way?
  Is there a way force a delay of addValueEventListener update lets say M miliseconds without my delta workarround?</p>
  <pre><code>val db = FirebaseDatabase.getInstance().reference.child(&quot;array_constantly_updated&quot;)
  val delta = 1200L
  var lastUpdate = 0L
  db.addValueEventListener(object : ValueEventListener {
      override fun onCancelled(p0: DatabaseError) {
      }
      override fun onDataChange(dataSnapshot: DataSnapshot) {
          if (System.currentTimeMillis()-lastUpdate&gt;=delta) {
              lastUpdate = System.currentTimeMillis()
          } else {
              return
          }
          //update UIView ...
          //update UIView 2 ...
          //update UIView 3 ...
          //update UIView 4 ...
          //update more views etc 
          //at some point is too much work for UI Thread
      }
  }
  </code></pre>