I would like to update a realm object from a listener but I get the following error
Error: Wrong transactional state (no active transaction, wrong type of transaction, or transaction already in progress)
const messagesRealm = realm.objects('message')
messagesRealm.addListener((messages, changes) => {
for (const index of changes.insertions) {
const channel = realm.objectForPrimaryKey('channel', messages[index].channelId)
if (!channel) continue
const message = messages[index]
channel.latestMessage = message
}
})