I have a bottom Sheet Fragment with MVVM which is observing a Firebase Search which is then added to a MutableLiveData.
The .observe(viewLifecycleOwner){it->} is never accessed when data is set from the firebase search even when data is added to the MutableLiveData
private var QrcodeSearch: MutableLiveData<ArrayList<FBAccountNameModel>> = MutableLiveData<ArrayList<FBAccountNameModel>>()
fun QrCodeScanSearch(QRCode: String) {
val profile = ArrayList<FBAccountNameModel>()
db.collection("UserProfiles").orderBy("UserUUID")
.startAt(QRCode)
.endAt("$QRCode\uf8ff")
.limit(5)
.get()
.addOnSuccessListener { snapshot ->
if (snapshot != null) {
Log.d("QRSearchProfileAll", "${snapshot.documents}")
val document = snapshot.documents
document.forEach {
val groupUser = it.toObject(FBAccountNameModel::class.java)
Log.d("QrUser", groupUser.toString())
if (groupUser != null) {
Log.d(
"QrSearchProfile",
groupUser.UserEmail + " " + groupUser.Username + " " + groupUser.UserUUID
)
profile.add(groupUser)
}
}
QrcodeSearch.value = profile
}
}
}
The query from firebase is being received as the correct data is Logged into logCat
internal var qrcodeSearch:MutableLiveData<ArrayList<FBAccountNameModel>>
get() { return QrcodeSearch}
set(value) {QrcodeSearch = value}
groupViewModel.qrcodeSearch.observe(viewLifecycleOwner){it ->
Log.d("QRCodeSearch Observed Data",it.toString())
}
The Observation of the data is never accessed and im unsure where to go even when the MuttableLiveData has data set from .value = , I have also tried *.postValue()