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);
Template.test.helpers({
processing: ()=> {
// or Template.instance().processing.get() ?
return processing.get();
}
});
Template.test.onCreated(function () {
// or declare processing here
// this.processing = new ReactiveVar(null);
});