New Component Life-Cycle Hooks

I see there are a few new component life-cycle hooks in Ember 1.13. What is the correct way to ‘hook’ into these events? I can’t seem to get them called.

I’ve tried both of these forms but my log message is never outputted to the console. I’m trying to find the life-cycle event where I do a one-time initialization of my component. I’m not even sure if this is the correct event to list to.

export default Ember.Component.extend({
     didReceiveAttrs: function(oldAtrs, newAttrs) {
         console.log('did receive attrs');
     }
});

And…

export default Ember.Component.extend({
     didReceiveAttrs(oldAtrs, newAttrs) {
         console.log('did receive attrs');
     }
});
App.FooBarComponent = Ember.Component.extend({
  didInitAttrs: function() {
    log('didInitAttrs');
  },
  
  didReceiveAttrs: function() {
    log('didReceiveAttrs');
  },
  
  willRender: function() {
    log('willRender');
  }
});
1 Like

Thank you. I found the issue. Somehow my project got pointed back to Ember 1.12. Those new hooks obviously aren’t available in v1.12. I’m all good now. Thanks.

@rwjblue Is there a writeup somewhere, or going to be a writeup about proper use of these hooks? I’m thinking of what kind of stuff should be moved from willInsertElement to willRender, etc. Perhaps things that will help with Fastboot support.

2 Likes