I am new to mobile development and I have been following advices from Alex Mamo's lecture and so far it has proven to be working. Now as I am trying to implement new things and fetch data, from one solution to another there are differences that seem to be incompatible.
I have Firebase Auth on this app and now I am trying to go and fetch data from Firestore and I get an IMPLICIT TYPE CASTING to ANY?
Here is what I am trying to achieve:
override fun getBudgetsFromFireStore() = callbackFlow {
val snapListener = db.collection(COLLECTION_NAME).orderBy("name").whereIn("id", listOf("I91xw6MUBpofeCmYYUCz"))
.addSnapshotListener { snap, e ->
val res = if (snap != null) {
val budgets = snap.toObjects(SettingBudget::class.java)
Success(budgets)
}else {
Error(e?.message ?: e.toString())
}
trySend(res).isSuccess
}
awaitClose {
snapListener.remove()
}
}
and here is the content of my Response sealed class:
sealed class Response<out T> {
object Loading: Response<Nothing>()
data class Success<out T>(
val data: T?
): Response<T>()
data class Failure(
val e: Exception
): Response<Nothing>()
so basically, I see that my T? is what forces the cast to ANY, but I can't seem to shake it off. I also have Firebase Auth flow that uses it, so I can't really play with it without messing things up!
Can anyone give me advice, on what option(s) could be available to me in that situation?
