Meteor 1.3 imports and variable definition


I used to declare all my template variable directly inside the onCreated() hook of a template, and then access the variables with Template.instance().
I recently started (after migration to 1.3) to define them directly in the scope of the file, is there any reason I should not do that ?
Since the variable are limited to the scope of the file, I don’t think anything can leak out of the template file…

const processing = new ReactiveVar(null);
    processing: ()=> {
        // or Template.instance().processing.get() ?
        return processing.get(); 

Template.test.onCreated(function () {
    // or declare processing here
    // this.processing = new ReactiveVar(null);


If your variable is associated with your Template, I would recommend keeping it attached to the Template itself. That way it will be cleaned up when you your Template is removed from the DOM and destroyed.


Good point, thx.
I should check more about the garbage collection and what exactly happens when the template is destroyed.