JJoe
JJoe

Reputation: 175

Realm query emit items on each write operation

Realm query emit items on each write operation. Even if the same data as stored in realm was written.

Upvotes: 0

Views: 30

Answers (1)

EpicPandaForce
EpicPandaForce

Reputation: 81539

Even if the same data as stored in realm was written.

Realm knows that you made a write operation to a given object, and that a given property was set to a given value.

It doesn't do an equality check and say "oh it's the same thing so I'm not going to write it" because that wouldn't work in Sync scenario.

And it also can't know that you "didn't mean to do a write", similarly to how if you write null or 0 as a value, it can't know you "didn't intend to set this value".

So the solution is that if you want to control your writes, then you should do it by hand: don't call the setter if the value is equal to that of the managed object's.

Upvotes: 1

Related Questions