What is the difference between Meteor.subscribe('tasks') and Meteor.subscribe('task').ready()


#1

Hi Guys,

I am new to meteor and a little confused about subscriptions. I find that my page flickers when I wait for a subscription to complete before rendering a template using iron router

Router.route('/admin/intake/create', function () {
this.layout('BasicLayout');
//This renders the dashboard template and then returns the data JSON array
this.render('intake_create', {to: 'cyclus_general'});
},{
  waitOn: function(){
   return Meteor.subscribe('tasks')
 }
});

but then there is no flicker if I use Meteor.subscribe(‘tasks’).ready() instead

This flicker seem to render my datepicker from jquery UI useless. So it would be good to know what the difference is between the two calls and if anyone knows why datepicker refuses to work after this page flickers, that would be an added bonus. I look forward to hearing any theories or experiences.


#2

If you are new to Meteor, don’t use Iron Router, or at least don’t use Iron Router subscription scheme. Use template-level subscription instead.


#3

Hmmm… but do you mind elaborating on the differences? It would be more helpful if you could explain to me what I am doing than saying I should use something else. I am not sure why I should use something else


#4

When you put any subscription in waiton block of iron router then it will wait until subscription ready. when it will ready this.ready() return true i am giving you example.

In below example i put todos of lists in wait on condition up to the package subscribe loader will be on page and when subscription ready then it will go to the data and check it is ready or not if it ready then page will load successfully

    this.route('listsShow', {
    path: '/lists/:_id', 
    onBeforeAction: function () {
 
    },
    waitOn:function (){
        //subscribe to todos before the page is rendered wait on the
      return  Meteor.subscribe('todos', this.params._id);
    },
    data: function () {
        //subscription, we'll just render the items as they arrive
        if(this.ready()){
            return {
                todos:Lists.findOne(this.params._id)
            }
        }
      
    },
    action: function () {
      this.render();
    }
  });