Open westman2000 opened 8 years ago
The solution here is to have the UseCaseHandler
return an object that implements something like cancel()
. The presenter needs to define a stop()
or unsubscribe()
method that the view will call once it gets detached.
Suppose there is such UseCase
And Presenter who using it.
When user start UseCase, i show loading, but because this is long running operation, user can close this screen(press back button, close activity), or even close application(press home button). In this case, will be called detachView() and onDestroyed() (presenter will be destroyed here)
But since the operation is continued in the background, presenter will receive
onSuccess(LongRunningUseCase.ResponseValue response)
but because view already detached, there will be Error.And my questions are:
isViewAttached()
. but maybe there is a more elegant solution? For example how I can unsubscribe from UseCase if presenter destroyed, and then callback will not be called?onSuccess
in the presenter, if presenter was already destroyed inMVPCPresenterLoader.onReset()