seal
Defines if instances of the map should be sealed in development.
Boolean
If true, in development, instances of this object will be sealed. In strict mode errors will be thrown when undefined properties are set. By default ObservableObjects are not sealed.
import { ObservableObject } from "can/everything";
class Person extends ObservableObject {
static seal = true;
}
const me = new Person();
try {
me.age = 33;
} catch(error) {
console.error( error.name + ": " + error.message ); //-> "TypeError: Cannot add property age, object is not extensible"
}
If false, the object will not be sealed. This is the default behavior of ObservableObjects.
import { ObservableObject } from "can/everything";
const person = new ObservableObject();
person.first = "Ada";
person.last = "Lovelace";
console.log( person.first ); //-> "Ada"
console.log( person.last ); //-> "Lovelace"