{"action":"opened","issue":{"url":"https://api.github.com/repos/sockeqwe/mosby/issues/134","repository_url":"https://api.github.com/repos/sockeqwe/mosby","labels_url":"https://api.github.com/repos/sockeqwe/mosby/issues/134/labels{/name}","comments_url":"https://api.github.com/repos/sockeqwe/mosby/issues/134/comments","events_url":"https://api.github.com/repos/sockeqwe/mosby/issues/134/events","html_url":"https://github.com/sockeqwe/mosby/issues/134","id":152030188,"number":134,"title":"Does mosby handle situation when View is de-attached on screen rotation?","user":{"login":"Try4W","id":5736157,"avatar_url":"https://avatars.githubusercontent.com/u/5736157?v=3","gravatar_id":"","url":"https://api.github.com/users/Try4W","html_url":"https://github.com/Try4W","followers_url":"https://api.github.com/users/Try4W/followers","following_url":"https://api.github.com/users/Try4W/following{/other_user}","gists_url":"https://api.github.com/users/Try4W/gists{/gist_id}","starred_url":"https://api.github.com/users/Try4W/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Try4W/subscriptions","organizations_url":"https://api.github.com/users/Try4W/orgs","repos_url":"https://api.github.com/users/Try4W/repos","events_url":"https://api.github.com/users/Try4W/events{/privacy}","received_events_url":"https://api.github.com/users/Try4W/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-04-30T13:26:02Z","updated_at":"2016-04-30T13:26:02Z","closed_at":null,"body":"What if some async work in `Presenter` will be finished in the moment when View is de-attached?\r\n\r\nFor example:\r\n1. User click 'do work' button\r\n2. `Presenter` does request to server(and doesn't stop work in de-attach method)\r\n3. Screen rotation in progress and `View` de-attached\r\n4. `Presenter` receives response from the server and wants to notify `View` about it. But there is no attached `View`.\r\n5. `View` is attached(in another orientation) and restore itself from `ViewState`. Response is executed, but View is not changed.\r\n\r\nIs it real situation? Or `de-attaching` and `attaching` `View ` is happening in one moment?\r\n\r\nThere is my solutaion:\r\n\r\n```\r\npublic abstract class BaseMvpPresenter<V extends MvpView> extends MvpBasePresenter<V> {\r\n\r\n    private Queue<Runnable> executeOnAttachQueue = new LinkedList<>();\r\n\r\n    public void executeOnAttachView(Runnable runnable) {\r\n        executeOnAttachQueue.add(runnable);\r\n    }\r\n\r\n    public void executeGranted(Runnable runnable) {\r\n        if(isViewAttached()) {\r\n            runnable.run();\r\n        } else {\r\n            executeOnAttachView(runnable);\r\n        }\r\n    }\r\n\r\n    @Override\r\n    public void attachView(V view) {\r\n        super.attachView(view);\r\n        while (!executeOnAttachQueue.isEmpty()) {\r\n            Runnable nextElement = executeOnAttachQueue.remove();\r\n            nextElement.run();\r\n        }\r\n    }\r\n}\r\n```\r\n\r\nBut do I really need it?"}}