Fixing setTimeout while the data loads?

Hey everyeone, here’s a snippet of code that is super annoying, because it means I have to guess for the data to be there. I wait 1 second, but some times this doesn’t work.

What is the correct way to wait for a data to load?

if(window.thePage == "trending"){

		dbSubscriptionUserMeta.clear();
		window.thisDbSubscriptionUserMeta = "";
		window.thisDbSubscriptionUserMeta = dbSubscriptionUserMeta.subscribe("findUserMeta", window.theUsername.split("/")[0]);
		
		//if(window.thisDbSubscriptionUserMeta.ready()) {
		setTimeout(function(){
			
			dbSubscriptionPosts.clear();
			window.thisDbSubscriptionPosts = "";
			window.thisDbSubscriptionPosts = dbSubscriptionPosts.subscribe('findPosts', "trending", window.theUsername.split("/")[0] );

			console.log("RENDER trending");
			BlazeLayout.render("user"); 	
			
		},1000);
		//}
	
		
	}

Hrmmm tracker… complex… seems to do what I need…

#LearnAnotherThing