What's the difference between rendered and onRendered?


#1

What is the difference between Template.myTemplate.rendered and Template.myTemplate.onRendered ?


#2

Template.foo.rendered has been deprecated and replaced with Template.foo.onRendered. onRendered is a function that takes a callback as an argument, while rendered was a property that you set to a function. onRendered is more versatile as you can call it multiple times to attach more than one callback.

/* Deprecated */
Template.foo.rendered = function () {}

/* Replaced with */
Template.foo.onRendered(function () {
  // ...
});

#3

And you have onCreated and onDestroyed now as well


#4

Thank you both for your prompt reply :slight_smile: