I have been utilizing the MobX library in conjunction with ReactJS, and it has integrated quite smoothly. Currently, I am working with an observable array structured as follows:
@observable items = [];
When I add an object in the following manner, everything works seamlessly, and the object becomes observable as intended.
let x = {
Title: "sample title"
}
items.push(x);
However, when attempting to define a strongly typed object using TypeScript like so:
export class SampleObject {
Title: string;
constructor(title: string) {
this.Title = title;
}
}
and then pushing a new object using this approach, it does not become observable.
items.push(new SampleObject("Sample Title"));
I am seeking a solution to this issue!
What distinguishes between objects x and y ?!
var x = {
Title: "sample"
}
var y = new SampleObject("sample");