icerockdev / moko-errors

Automated exceptions handler for mobile (android & ios) Kotlin Multiplatform development.
https://moko.icerock.dev/
Apache License 2.0
52 stars 6 forks source link

Sometimes handeled errors are not displayed on iOS #3

Closed Tetraquark closed 4 years ago

Tetraquark commented 4 years ago

It seems that there is a problem with ARC on iOS that kills the anonymous object of the listener:

actual class ExceptionHandlerBinderImpl<T : Any> actual constructor(
    private val errorPresenter: ErrorPresenter<T>,
    private val eventsDispatcher: EventsDispatcher<ErrorEventListener<T>>
) : ExceptionHandlerBinder {
    override fun bind(viewController: UIViewController) {
        eventsDispatcher.listener = object : ErrorEventListener<T> { // anonymous object
            override fun showError(throwable: Throwable, data: T) {
                errorPresenter.show(throwable, viewController, data)
            }
        }
    }
}