The object to be extended and observed.
The properties to add to the target object.
Optional
overrides: { Optional overrides to define the type of the reactive property. If an override is false, the key will be ignored.
Optional
options: { Options to configure the observable behavior.
The name of the observable object. Defaults to an empty string. Using as prefix for reactive property names.
The extended object with observable properties.
let object = {
value: 0,
get double() {
return this.value * 2;
},
increment() {
this.value++;
},
};
makeObservable(object, { value: "atom", double: "computed" });
extendObservable(object, {a: 1, b: 2});
let foo = 0;
autorun(() => {
foo++;
object.a;
});
console.log(foo); // 1
object.a++;
console.log(foo); // 2
Extends an object with new properties and makes them observable.