One Blaze pattern that I am very fond of is ditching helpers and storing everything on the template instance. In onCreated:
Template.templateName.onCreated(function() {
let tpl = this;
_.extend(tpl, {
someState: new ReactiveVar([], EJSON.equals),
initialize(params) {
// do whatever initialization e.g.:
tpl.listenForChanges();
},
listenForChanges() {
tpl.autorun(comp => ...);
},
useThisInsteadOfHelper(arg1, arg2) {
},
}).initialize(tpl.data);
});
Then if you declare a global helper:
Template.registerHelper('$tpl', function () {
return Template.instance();
});
You can do {{$tpl.useThisInsteadOfHelper arg1 arg2}} or {{$tpl.someState.get}} inside of the templateName html file. This means that your functions can call each other, store state on the template instance without calling Template.instance() everywhere, and aren’t run everytime anything in the data context changes (if you want the function to rerun whenever anything in the data context changes you have to explicitly call Template.currentData()). This gives waaaay more flexibility.