Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I need advice. branch/todo-mvp-clean. LongRunningUseCase #154

Open
westman2000 opened this issue Aug 23, 2016 · 1 comment
Open

I need advice. branch/todo-mvp-clean. LongRunningUseCase #154

westman2000 opened this issue Aug 23, 2016 · 1 comment
Labels

Comments

@westman2000
Copy link

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:

  1. How to avoid this error? I understand i can just check if view is attached 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?
  2. I do not understand how and why there is a function call onSuccess in the presenter, if presenter was already destroyed in MVPCPresenterLoader.onReset()
  3. Somebody thought to create an intermediate buffer(let's called ViewState) between the Presenter and View to save commands for the View. In case you Presenter was disconnected from the View, and background thread finish loading, we need to hide the ProgressBar and display data. But this commands must be send to View only after attachView... In generally i speak about somesing like this
@ErikHellman
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants