Any plannings for adding these function? `<R, T...
# compose
a
Any plannings for adding these function?
<R, T : R> LiveData<T>.observeAsState(initial: R, *policy: SnapshotMutationPolicy<R>*): State<R>
a
No plans to so far. What's your use case?
a
Maybe very special case.
LiveData<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()
a
Yeah I agree with immutable being the best answer in this case