title: Make sure that all Firebase single ValueEventsListeners finished
body: <p>As mentioned in docs, it's better to fetch additional data, than nest objects in database. </p>
  
  <p>According to this, how can I ensure that all data came?</p>
  
  <p>I came up to this solution, but I'm not sure if this will work.</p>
  
  <pre><code>mPetsReference.addValueEventListener(new ValueEventListener() {
      private List&lt;Pair&lt;Pet, Owner&gt;&gt; mData;
      private long mChildrenCount;
      @Override
      public void onDataChange(DataSnapshot dataSnapshot) {
          mData = new ArrayList&lt;&gt;();
          mChildrenCount = dataSnapshot.getChildrenCount();
          for (DataSnapshot data : dataSnapshot.getChildren()) {
              Pet pet = data.getValue(Pet.class);
              mOwnersReference.child(pet.getOwnerId())
                      .addListenerForSingleValueEvent(new ValueEventListener() {
                          @Override
                          public void onDataChange(DataSnapshot dataSnapshot) {
                              mData.add(new Pair&lt;&gt;(pet, dataSnapshot.getValue(Owner.class)));
                              if (mData.size() == mChildrenCount) {
                                  everythingCame();
                              }
                          }
                          @Override
                          public void onCancelled(DatabaseError databaseError) {
                              mChildrenCount--;
                              if (mData.size() == mChildrenCount) {
                                  everythingCame();
                              }
                          }
                      });
          }
      }
      @Override
      public void onCancelled(DatabaseError databaseError) {
      }
  });
  </code></pre>