This is my first exposure to Meteor, though I have heard only good things, I’ve already run into some stumbling blocks. I’ve already got a parse.com database, and I wan’t to use the data without have to port or mirror to Meteor. I have been attempting make an Asynchronous calls to parse on the server by placing the function into a method, and returning that value to a reactive var inside template.created. I’ve tried fibers, future, and every other method that I have read about but nothing works. Am I barking up the wrong tree using Meteor for this project? should I stick with MEAN or Sails. My application has a lot of asycronisity at it’s core. here is some of my code
on the client
Template.venues.created = function (){
console.log('template created')
var self = this;
self.myAsyncValue = new ReactiveVar("Waiting for response from server...");
Meteor.call('get_venues', function (err, asyncValue) {
if (err)
console.log(err);
else
self.myAsyncValue.set(asyncValue);
console.log('asyncValue'+asyncValue);
});
}
on the server
Meteor.methods({
'Items.insert': function (params) {
Items.insert(params);
},
'Items.findthem': function (params) {
return {};//Items.find(params);
console.log('test');
},
get_venues: function(params) {
function getVenues(cb)
{
var Venue = Parse.Object.extend("Venue");
var query = new Parse.Query(Venue);
query.find({
success: function(results) {
console.log("Successfully retrieved " + results.length + " scores.");
console.log(results.length);
cb(null, "Tester");
//return results
},
error: function(error) {
console.log("Error: " + error.code + " " + error.message);
cb(error, null);
}
})
}
var Future = Npm.require('fibers/future');
var fut = new Future();
var bound_callback = Meteor.bindEnvironment(function (err, res) {
if(err) {
fut.throw(err);
console.log("return err")
} else {
fut.return(res)
console.log("return res")
}
});
getVenues(bound_callback);
fut.wait();
}
});
what am I missing conceptually ?