Could I use chainable method on Template.x.helpers().events

Could I use chainable method on Template.x.helpers().events…?

Template.nyTemplate.helpers({
...
})
.events({
})
....
...

You could perhaps wire it up using underscore chain and mixins.

But helpers and events are two very different things, so why would you want that?

Because i don’t write duplicate

Template.nyTemplate.helpers();

Template.nyTemplate.events();

Template.nyTemplate.onRendered();

If by duplicates, you mean template inheritance, you can take a look at https://atmospherejs.com/aldeed/template-extension otherwise, I don’t quite understand what you’d actually achieve with chaining since chaning is a construct that allows passing function I/O through a predefined path of functions, in which helpers, events and the onRendered callbacks do not seem to share any common I/O except for the template instance, which itself is already available to each of them separately.

Not an answer to your question, but I usually write it as this:

var T = Template.nyTemplate

T.helpers();

T.events();

T.onRendered();

And I call the functions in the same order as Meteor will (for example onRendered before events).

1 Like

Kudos! You my hero :smile: