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

Capture and play voice with Asterisk ARI -

c++ - Can not find the "fiostream.h" file -

java - Why database contraints in HSQLDB are only checked during a commit when using transactions in Hibernate? -