Ensure clearWith lambda is deleting all the list item, else we will get an infinite loop. This specific error will help to figure out what is happening.
This commit is contained in:
parent
69920a6e46
commit
9866bfefed
|
@ -30,7 +30,11 @@ internal fun RealmObject.assertIsManaged() {
|
|||
*/
|
||||
internal fun <T> RealmList<T>.clearWith(delete: (T) -> Unit) {
|
||||
while (!isEmpty()) {
|
||||
val previousSize = size
|
||||
first()?.let { delete.invoke(it) }
|
||||
if (previousSize != size + 1) {
|
||||
error("`clearWith` MUST delete all elements of the RealmList")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue