epoxy
epoxy copied to clipboard
Can only call this when inside the `buildModels` method ?
Hello everyone, I am facing a problem with my chat application.
Epoxy: 4.2.0
Reported from Firebase crashlytics
Fatal Exception: com.airbnb.epoxy.IllegalEpoxyUsage
Can only call this when inside the `buildModels` method
com.airbnb.epoxy.EpoxyController.assertIsBuildingModels (EpoxyController.java:463)
com.airbnb.epoxy.EpoxyController.addInternal (EpoxyController.java:510)
com.airbnb.epoxy.EpoxyModel.addTo (EpoxyModel.java:350)
I have used RxKotlin with 2 threads ( IO and Main Thread ) for calling update Models ( requestModelBuild or requestDelayedModelBuild(delayMs)
)
Case 1:
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
Case 2
.subscribeOn(Schedulers.io())
.observeOn(Schedulers.io())
I have called cancelPendingModelBuild()
before requestModelBuild or requestDelayedModelBuild(delayMs)
private fun requestBuild(delayMs: Int = 0) {
cancelPendingModelBuild()
try {
if (!isBuildingModels) {
if (delayMs <= 0) {
requestModelBuild()
} else {
requestDelayedModelBuild(delayMs)
}
}
} catch (e: Exception) {
Timber.e(e)
}
}
How to resolve this fatal/crash in Epoxy ?
Have you solved it?