title: How to listen to a specific value change in Firebase?
body: <p>My data structure is the following: compliments/received/{uid}/{complimentId}
  <a href="https://i.stack.imgur.com/k5SlA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k5SlA.png" alt="enter image description here"></a></p>
  
  <p>I would like to listen to changes on compliments/received/{uid}/{complimentId}/updatedAt</p>
  
  <p>My code is: </p>
  
  <pre><code>firebase.database().ref('compliments/received/' + currentUser._id).on('child_changed', (snap) =&gt; {
    console.log('update in action', snap.val())
    snap.ref.child('updatedAt').on('value', () =&gt; onUpdate(snap))
  });
  </code></pre>
  
  <p>The problem:
  This listener triggers when I update any field on the given database path, eg: when I set "seen" from 0 to 1. I would like to trigger this listener only when the updatedAt field's value changes. </p>
  
  <p>What I tried so far:</p>
  
  <pre><code>firebase.database().ref('compliments/received/' + currentUser._id).on('child_changed', (snap) =&gt; {
    console.log('update in action', snap.val())
    snap.ref.child('updatedAt').on('child_changed', () =&gt; onUpdate(snap))
  });
  </code></pre>
  
  <p>This listener does not trigger when I change the updatedAt field's value.</p>
  
  <p>Any recommendations are welcome!
  Thanks!</p>
  
  <p>Solution as per Ali's answer: </p>
  
  <pre><code>firebase.database().ref('compliments/received/' + currentUser._id).on('child_added', (snap) =&gt; {
      console.log('add in action', snap.val());
      firebase.database().ref('compliments/received/' + currentUser._id)
      .child(snap.key).child('updatedAt').on('value', async () =&gt; {
        const newSnap = await firebase.database().ref('compliments/received/' + currentUser._id)
        .child(snap.key).once('value')
        onUpdate(newSnap)
      })
  });
  </code></pre>