It doesn’t make much sense in this case but it’s a godsend for packages. In my case one of my packages is now able to add code onCreated, onRendered, and then do some cleanup onDestroyed. This without affecting the consumer of the package (because they can add their own onRendered and the others).
Sure, it’s all part of the plain JS function. That’s why I said in this case it doesn’t make much sense, because you can just put the two statements in the same function.
@manuel thanks much clearer now. Yes I agree I don’t like and feels like repetitive code when creating two on render methods just to call two different functions.
First I cannot say enough amazing things about Meteor and I’m constantly evangelizing it to anyone I can. It’s an amazing framework!
I would like to request a very simple, yet what would be an incredibly helpful thing. In the official documentation give example code snippets for every topic. This has been a point of struggle for at least me as I dig deeper and deeper into the framework. This is my case in point right here. I’m building up a new view in my app and I wanted to leverage the new this.subscription functionality at the Template level along with the new onCreate, onRender, onDestroy, etc. functions. I have been spinning my wheels for more time then I’d like to admit trying to figure this out. I finally found this post. Thank you @almog for asking this very question.
Adding to the documentation @manuel’s code snippet he provide @almog would I’m sure not just help the two of us out but others as well.
Template.myTemplate.onRendered(function () {
});
All I needed to see was this and it all clicked instantly. Please consider including examples for every topic on the documentation.