Alexander Karkossa
12/20/2020, 10:46 AM<R, T : R> LiveData<T>.observeAsState(initial: R, *policy: SnapshotMutationPolicy<R>*): State<R>
Adam Powell
12/20/2020, 2:59 PMAlexander Karkossa
12/20/2020, 6:05 PMLiveData<List<Person>>
from Database.
List which shows persons, markable as favourite. The Person is not immutable so you set isFavourite = true
.
Insert it into Database.
-> The View will not recompose.
Reason: Because of the EqualityPolicy. isFavourite is already true in that person.
Workaround 1 (seems best/the way we use it at the moment): Make person immutable -> call: db.insert(person.copy(isFavourite = true))
Workaround 2: Don't use data class
which generates these smart equals methods...
Thought: Maybe the are cases where i would change the policy simmilar to the mutableStateOf()Adam Powell
12/20/2020, 6:48 PM