ManuelDeLeon / viewmodel

MVVM for Meteor
https://viewmodel.org
MIT License
205 stars 23 forks source link

onRendered doesn't get current template instance as argument #308

Closed arggh closed 6 years ago

arggh commented 6 years ago

onCreated and onDestroyed receive the current template instance as argument, so stuff like this is convenient:

onCreated(instance) {
   instance.subscribe('docs');
}

Is there a reason, why onRendered doesn't receive the template instance as argument? In Blaze it's bound as this in all three life cycle functions, so it would make sense to have a similar behavior across all of them in ViewModel as well?

ManuelDeLeon commented 6 years ago

Gonna need a repro. The following works:

Template.body.viewmodel({
  onRendered(instance) {
    console.log(instance);
  }
});
arggh commented 6 years ago

I have no idea what happened then. Probably some silly human error. I just tried this in a random component and indeed it works like you said. Sorry for the trouble, closing.