Can someone please explain this error message? ```...
# rx
n
Can someone please explain this error message?
Copy code
Exception in thread "UI thread @coroutine#1" java.lang.ClassCastException: io.reactivex.Observer$Subclass1 cannot be cast to com.nikolam.basketpro.ui.drills.selection.DrillsSelectionViewModel$fetchDrillTypes$1$disposable$1
	at com.nikolam.basketpro.ui.drills.selection.DrillsSelectionViewModel$fetchDrillTypes$1.invokeSuspend(DrillsSelectionViewModel.kt:37)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:56)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:180)
	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:293)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
I get a passing test with correct data but I also get this error (code in thread so I dont spam)
This is the test
Copy code
@Test
    fun `will populate livedata with correct value, when repository returns correct data`() {
        val expectedDrillTypeOne = DrillsType("title1", "url1")
        val expectedDrillTypeTwo = DrillsType("title2", "url2")

        every { mockDrillRepository.loadFullDrillType() } returns Observable.just(expectedDrillTypeOne, expectedDrillTypeTwo)

        drillsSelectionViewModel.fetchDrillTypes()

        val data = drillsSelectionViewModel.drillsTypeList.getOrAwaitValue()

        assertEquals(arrayListOf(expectedDrillTypeOne, expectedDrillTypeTwo), data )
    }
This is the fun
Copy code
fun fetchDrillTypes() {

        val list = ArrayList<DrillsType>()

        viewModelScope.launch(io) {

            val disposable = repository.loadFullDrillType()
                .subscribeWith(object : DisposableObserver<DrillsType>() {

                    override fun onError(e: Throwable) {
                        Log.d("TAG", "error " + e.message)
                    }

                    override fun onNext(data: DrillsType) {
                        Log.d("TAG", "data is $data")
                        list.add(data)
                    }

                    override fun onComplete() {
                        Log.d("TAG", "COMPLETE")
                        _drillsTypeList.postValue(list)
                    }
                })

            compositeDisposable.add(disposable)
        }
    }
The app itself works, but the tests pass but error is thrown. Idk what is happening, I had this problem for somewhile and moving the disposable and everything around fixed it I believe, I don't remember what I did exactly. I'd like to understand what is going on