Skip to content

Instantly share code, notes, and snippets.

View nyxee's full-sized avatar

Andrew Nyago nyxee

  • Kampala
  • 01:19 (UTC +03:00)
View GitHub Profile
//INITIAL POSITION
class ClubsViewModel(): BaseViewModel() {
private var _mClubs = MutableLiveData<ArrayList<ClubFSEntity>>()
...
private fun listenToFireStoreClubs() {
mFirestore.collection("Clubs").addSnapshotListener { snapshot, e ->
// if there is an exception we want to skip.
if (e != null) {
return@addSnapshotListener
@nyxee
nyxee / currentPosition.kt
Last active April 6, 2021 23:07
The Problem has been solved
//CURRENT POSITION
class ClubsViewModel<T> (clazz: Class<T>) : BaseViewModel<T>(clazz) { //<< THIS IS WHERE THE CURRENT PROBLEM WAS.
private var _mClubs = MutableLiveData<List<T>>()
listenToFireStoreCollection("Clubs", _mClubs)
...
}
class BViewModel<T> (clazz: Class<T>) : BaseViewModel<T>(clazz) { //<< THIS IS WHERE THE CURRENT PROBLEM WAS.
@nyxee
nyxee / providersForGenerics.kt
Last active April 7, 2021 10:53
Hilt and Generic classes in ViewModels
class ClubsViewModel<T> @ViewModelInject constructor(clazz: Class<T>) : BaseViewModel<T>(clazz) {
listenToFireStoreCollection("Clubs", _mClubs)
...
}
class BViewModel<T> @ViewModelInject constructor(clazz: Class<T>) : BaseViewModel<T>(clazz) {
private var _mBs = MutableLiveData<List<T>>()
listenToFireStoreCollection("Bname", _mBs)
...