meteor - Data from db undefined at first, then changes to actual data -


i doing find on collection of nodes , storing info in variable.

i console.logging data see contents of it. thing is, data stays empty array split second , new console.log done array of data. see code below:

template.temperature.helpers({     node() {         let node = nodes.find({_id:session.get('selectednode')});         console.log(node);         return '';     } }); 

my console output:

1: [] 2: [object] 

what reason this?

in router, subscribe within waiton:

router.route('/home', {     waiton: function() {         return [             meteor.subscribe('nodes'),         ];     },     action: function() {         if (this.ready()) {             this.render();         }     }, }); 

this ensure route wait until subscription completed before executing route. uses meteor loading hook, wait utilize whatever loading screen or animation ahve setup.


Comments

Popular posts from this blog

ruby - Trying to change last to "x"s to 23 -

jquery - Clone last and append item to closest class -

css - Can I use the :after pseudo-element on an input field? -