Within my service class, I have an array of quests defined in the following manner:
import { ObservableArray, ChangedData } from 'tns-core-modules/data/observable-array/observable-array';
quests: ObservableArray<Quest>;
To add quests to the array, I use the following code:
let quest = new Quest(data.key, data.value["name"], data.value["description");
this.quests.push(quest);
In a different class, I subscribe to change events of this array:
this.myService.quests.on(ObservableArray.changeEvent,(args:ChangedData<Quest>) => {
console.log(args.object);
let quest: Quest = args.object; // can not cast to quest
});
Although I can see my data inside the ChangedData
object in the log, I am struggling to cast it back to my object.
Is there a way to accomplish this successfully?
Thank you.