jax
jax

Reputation: 38593

run a function when an Ember.Object is created

I need to run a function when a particular object is created to validate the environment is setup correctly.

This works on an Ember.Controller but not on an Ember.Object.

checkEnvironment : function() {

    ...

}.on('init'),

Is there a way to hook into the contructor somehow?

Upvotes: 0

Views: 26

Answers (1)

Asgaroth
Asgaroth

Reputation: 4334

Functions don't really have an on method, perhaps you are confusing them with observers?

fullNameChanged: function() {
   // deal with the change
}.observes('fullName').on('init')

What you can do, is override the init methid, and call this._super()

  init: function() {
    this._super();
    this.checkEnvironment();
  },

Upvotes: 1

Related Questions