I have a function publicRooms to display public discussions that are on the server. I want to use this data for another function I created addNewMessageNewThread:
matrixClient.publicRooms(function(err, data) {
console.log("Public Rooms: %s", JSON.stringify(data));
console.log("data", data.chunk[0].aliases[0]);
this.addNewMessageNewThread({
'id': 'paul',
'author': 'Paul Manip',
'body': ' ?'
});
});
Off when I do that, he tells me he does not know this function :
ERROR TypeError: Cannot read property 'addNewMessageNewThread' of undefined
And when I test this function outside the function, it works
///////////EDIT//////////////
This is my function addNewMessageNewThread() :
addNewMessageNewThread(objMessage: any): void {
const newUser: User = new User(objMessage.author, objMessage.site);
const newThread: Thread = new Thread(objMessage.id, [newUser],objMessage.title);
const newMessage = new Message(objMessage);
objMessage.date = moment().toDate();
newThread.arrayMessages.push(newMessage);
newThread.messages = Observable.of(newThread.arrayMessages);
newThread.lastMessage = newMessage;
objMessage.thread = newThread;
this.addThread(newThread);
}
addNewMessageNewThread()do? Is it by any chance asynchronous?