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 !
wrapAsyncis to make asynchronous code look synchronous thanks to Fibers and only work in a Node environment (the server). On the client, you're stuck with classical asynchronous. - Kyll