Reputation: 69
This is another asynchronous topic for meteor, and i'm sorry for that ! I read so much things about wrapasync, promise, future, fibers etc... that i'm a bit lost !
My problem is simple, in my code I just want a return of the server who is returning the current hostname from :
"getHost" : function(){
return this.connection.httpHeaders.host;
}
I'm calling this at the beggining of my program in the onCreated helper :
Template.printjoblistList.onCreated(function () {
Meteor.call("getHost", function(err, data){
if(err){
console.log("error " + err + " : " + data);
}else {
Session.set("printJobList_Host", data)
}
});
});
The problem is : I have my Session.set who are executed after my Session.get. This Session.get is executed by this :
In my template :
<a href="{{getPdf}}">{{getPdf}}</a>
In my helper :
Template.registerHelper("getPdf", function() {
var myReturn = Session.get('printJobList_Host'); + "/pdf/" + pdfFileName;
return myReturn;
});
So, I would like to understand how to use wrapAsync to get this clearly ! Thanks for your help !
Upvotes: 0
Views: 229
Reputation: 20768
The Session.get
may happen before the Session.set
, but that should be fine, because when the Session.set
is called, the Session.get
will be called again too (at least it is the case in a regular helper.)
If that doesn't work for you, try using the Session.get
inside a Tracker.autorun()
Upvotes: 1