Skip to content

Commit

Permalink
unbind related info in bind step
Browse files Browse the repository at this point in the history
  • Loading branch information
adroitandroid committed Jun 28, 2017
1 parent 87502b3 commit 595970d
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions GettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,18 +109,21 @@ public abstract class XPresenter<vView extends XView, vPresenterModel extends XP
```
Examples using this can be found [here](/app).

## Step 4 - Saving State
This might, as per your use case, be a requirement. Good part about MVX is that it allows to save the state without passing in bundles. That's because the PresenterModel we just saw, is actually an Android Service, and the Presenter an implementation of IBinder!
We just need to put a few Presenter method calls at the right lifecycle methods of the Activity or Fragment to enable state saving, namely the following.
Finally, remember to unbind the bound Presenter.
```java
public class MainActivity extends AppCompatActivity implements MainView {
...
@Override
protected void onDestroy() {
super.onDestroy();
mPresenter.unbind(this);
}
```

## Step 4 - Saving State
This might, as per your use case, be a requirement. Good part about MVX is that it allows to save the state without passing in bundles. That's because the PresenterModel we just saw, is actually an Android Service, and the Presenter an implementation of IBinder!
We just need to put a few Presenter method calls at the right lifecycle methods of the Activity or Fragment to enable state saving, namely the following.
```java
public class MainActivity extends AppCompatActivity implements MainView {
...
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
Expand Down

0 comments on commit 595970d

Please sign in to comment.