title: Firebase listen for changes in number of likes and display it on screen
body: <p>When user doubletap on the image,the number of likes(heart) will increase for each post.
  I tried this code but it does not work as expected(For eg when i double tap,it will load one post and duplicate it with different number of likes(Eg Post 1-1like,Post 1-2like,Post 1-3like).How do i display the updated number of likes without duplicating the post?(Post 1- Displaying the X number of likes where X=Incremental)</p>
  
  <pre><code>func loadPosts() {
  let ref = Database.database().reference()
  ref.child("posts").observe(.childAdded) { (snapshot: DataSnapshot) in
      if  let dict = snapshot.value as? [String: Any] {
          guard let titleText = dict["title"] as? String else{return}
          let locationDetails = dict["location"] as! String
          let captionText = dict["caption"] as! String
          let photoUrlString = dict["photoUrl"] as! String
          let priceText = dict["price"] as! String
          let categoryText = dict["category"] as! String
          let usernameLabel = dict["username"] as! String
          let profileImageURL = dict["pic"] as! String
          let heartInt = dict["heart"] as! Int
          let timestampString = dict["timestamp"] as! String
          let post = Post(titleText: titleText, captionText: captionText, locationDetails: locationDetails, photoUrlString: photoUrlString, priceText: priceText,categoryText: categoryText, usernameLabel: usernameLabel, profileImageURL: profileImageURL, heartInt: heartInt, timestampString: timestampString)
          //append(post) to array
          self.posts.append(post)
          print(self.posts)
          self.collectionView.reloadData()
  
      }
  }
  }
  
  func delayCompletionHandler(completion:@escaping (() -&gt; ())) {
      let delayInSeconds = 0.5
      DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + delayInSeconds) {
          completion()
      }
  }
  //CollectionView
  func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell{
   cell.reloadEvents = {
      self.delayCompletionHandler {
      self.loadPosts()
      }
  }
  }
  </code></pre>
  
  <p>To detect the heartTapped which is in another file:</p>
  
  <pre><code>@objc func heartTapped(){
          print(" I heart u")
          let ref = Database.database().reference()
          heartInt1 += 1
          ref.child("posts").child(timestamp).observeSingleEvent(of: .value, with: { (snapshot) in
              if let dic = snapshot.value as? [String : AnyObject]{
                  var heartString = dic["heart"] as! Int
                  heartString += 1
                  ref.child("posts").child(self.timestamp).updateChildValues(["heart" : heartString])
              }
      })
      reloadEvents?()
  }
  }
  </code></pre>