EmberJS Observers

The eyewitness watches the property, for example, registered properties and updates the content of the processed property.


funName1: Ember.computed(function() { 

/code here 


funName1: Ember.observer(function() { 

/code here 


var varname = ClassName.create({ 

/code here 


The following table records down the properties of an eyewitness −


The following model tells the best way to refresh the content of processed property by utilizing onlooker −

import Ember from 'ember'; 

export default function() { 

var Person = Ember.Object.extend ({ 

Name: null, 

//Defining the Details1 and Details2 figured property function 

Details1: Ember.computed('Name', function() { 

//get the Name value 

var Name = this.get('Name'); 

//return the Name value 

return Name; 


    Details2: Ember.observer('Details1', function() { 

this.set('Name','Roman '); 



//introducing the Person details 

var individual = Person.create ({ 

//starting estimation of Name varialble 

Name: 'Roman ' 


//refreshing the incentive for 'firstName' utilizing set() method 

document.write('<strong>The refreshed name : </strong>' +person.get('Details1')); 


Now open the app.js record and include the accompanying line at the highest point of the document −

import onlookers from './spectators'; 

Where, onlookers is a name of the document determined as "observers.js" and made under the "application" envelope. Presently, call the acquired "onlookers" at the base, before the fare. It executes the eyewitnesses work which is made in the observers.js record −