Collection use - how it's work

Hi, i have problem with collection.
I have two files .js and html view template:

html

    <div id='id'></div>

</template>

js

 CalendarViewController = CustomController.extend({
    controller: 'CalendarViewController',
    template: 'calendar.view',
    menu: 'menu-calendar',
    onRender: function() {
        Meteor.subscribe("AllHolidays");

        CalendarHelper.test();

 

    },
    helpers: {


    },
    events: {

    },
    autoFormHooks: {

    }
});

js

CalendarHelper = {
   test:function(){
  console.log (HolidaysCollection.findOne());
    return false;
},

};

When i call CalendarHelper.test from secound js file in first js file it doesnt work, it cant find enything and in web console i get “undefined”. But when i write event in first js file

 events: {
    'click': function(){
 CalendarHelper.test();
}
        },

Then it works!
I dont understand it!
Could someone say me why it happens?

You can indicate where is the folder your code is located at?

It looks like CalendarHelper.test(); is being called before the subscription is complete.

try this

Meteor.subscribe("AllHolidays", function(){

    CalendarHelper.test();

}); // it will call when the subscription is ready

note - this may not be the case because your question was quite hard to follow. Also I’m not sure if the subscription and the collection are related, I’m assuming that they are but the naming strategy doesn’t make that clear.