The variable Models will store an array of model objects.
SelectedIndex
will get changed by the UI through the action setSelectedIndex
.
The Action addToResult
should add the incoming data to the selected model and It should get reflected in the UI
as well.
Here The problem is that, after executing the action addToResult
, UI
does not get updated.
export default class Store {
selectedIndex: number = -1
@observable.deep activeModel: Model = undefined
@action addToResult = (results: string[]) => {
this.model[this.selectedIndex].results.push(results[0])
}
@action setSelectedIndex = (index: number) => {
this.selectedIndex = index
this.activeModel = {
...this.models[this.selectedIndex]
}
}
models: Model[] = []
constructor () {
makeObservable(this)
}
}