Javascript / Meteor Android Return Objects To Templates
I have the following piece of code in my meteor app if (Meteor.isClient) {   Meteor.startup(function(){      var onSuccess = function(acceleration){       alert( acceleration);
Solution 1:
You need to have the template update reactively when the data changes. To do that set up a reactive variable that gets updated by the callback. First, install the package:
meteor add reactive-varThen, when the template is created, create the reactive variable and start watching the callbacks:
Template.rawData.onCreated(function() {
   self = this;
   self.rawValue = new ReactiveVar();
   self.accWatchID = navigator.accelerometer.watchAcceleration(
      function(acc) { self.rawValue.set(acc); }, function() {}, { frequency: 3000 }
   );
});
Your template helper can then return the value of the reactive variable, and your template will be updated whenever it changes:
Template.rawData.helpers({
   acc: function() {
      returnTemplate.instance().rawValue.get();
    }
 });
(Note that in your original code, since the alert wasn't being called, there must be a problem in your template. Does it have the right name?)
Finally, you should stop the callback when the template is destroyed:
Template.rawData.onDestroyed(function() {
   navigator.accelerometer.clearWatch(this.accWatchID);
});
Note that I've just typed that code here without testing it. You may need to fine tune it a little if it doesn't work straight away.
Post a Comment for "Javascript / Meteor Android Return Objects To Templates"