When should a RealtimeDictionary update?

Say I do something like this:

var temp = rootModel.users[userID];
temp.muted = true;
rootModel.users[userID] = temp;

Where .users is a RealtimeDictionary of a RealtimeModel named UserModel, and .muted is a RealtimeProperty with reliable set to true on UserModel.

According to this:

“A model is considered replaced (as opposed to removed and added) if a new model is added that overwrites an existing model under the same key.”

But when I do this, it activates the users.modelReplaced on the local computer, like you would expect. But on the remote computer, it activates users.modelRemoved and users.modelAdded

I originally was doing this:

rootModel.users[userID].muted  = true;

But it didn’t seem to be syncing that property correctly, (muted and then I came across this:

Which did the thing with reassigning the whole value but then that is interpreted as modelRemoved and modelAdded on the remote computer, which is not ideal.

So what am I misunderstanding about how the RealtimeDictionary works?

Wow this is a really strange one. I’ll file a bug for it. That said, ideally you don’t have to replace the model at all. All you need to do is this:

rootModel.users[userID].muted = true;

and then use the change event for muted on the model itself rather than swapping the entire model every time you make a change.


I guess I was only resorting to that because changing it didn’t seem to change the value on the other computer. But adding it to the RealtimeDictionary always showed up on the other computer, and would have the correct value it was added with.