Function

Module: @ember/object
import { readOnly } from '@ember/object/computed';
returns
ComputedProperty
this

Call on a computed property to set it into read-only mode. When in this mode the computed property will throw an error when set.

1
2
3
4
5
6
7
8
9
10
11
import EmberObject, { computed } from '@ember/object';

let Person = EmberObject.extend({
  guid: computed(function() {
    return 'guid-guid-guid';
  }).readOnly()
});

let person = Person.create();

person.set('guid', 'new-guid'); // will throw an exception