I am trying to use Convergence for the SlateJS rich text editor and am having trouble seeing change events in my RealTimeElement.
Here is a basic example of the data I would like to store in Convergence:
Each item in the root list is a node in the editor. If a remote user were to make a change to the “hello” text in the first item, I need to handle this event and update my editor state appropriately. Here’s what I tried so far:
Let doc be a variable of type RealTimeArray that contains the above data. Also let doc be contained in a RealTimeModel under the key “content”. Finally, when a character is added to one of the text fields, I isolate it, cast it to a RealTimeString, and call insert passing the relative offset and added character.
I tried listening for any changes to doc by doing
doc.on(ModelChangedEvent.NAME, event => console.log(event))
But nothing is logging to the console. Next, I tried subscribing to events on doc with
doc.events().subscribe(event => console.log(event))
But still nothing is logged when I insert characters into the text field. Finally, I’ve tried to assign an event listener to each item in the root list, as I assume these are each RealTimeObjects, and listening for granular changes is apparently more efficient. But this also didn’t appear to be catching any of the insert events. What am I doing wrong?
Thanks in advanced!