The following is the first few sections of a chapter from Exploring Android, plus headings for the remaining major sections, to give you an idea about the content of the chapter.

Completing the MVI Flow

We have all of the pieces necessary to build the Model-View-Intent (MVI) flow that we want. Now, we just need to make the final connections, getting our app back to the working state it was in before we started in on this round of changes. This also sets us up for saving our items to a database in upcoming tutorials.

This is a continuation of the work we did in the previous tutorial. The book’s GitHub repository contains the results of the previous tutorial as well as the results of completing the work in this tutorial.

Step #1: Publishing Results

Our Controller needs to emit Result objects when it is done processing the Action that triggers those results. We can use RxJava for this as well, so that objects needing those results can subscribe to them, control what thread those results are delivered upon, etc.

To that end, add this resultSubject field to Controller:

  private final PublishSubject<Result> resultSubject=

This sets up another RxJava Subject, akin to the PublishSubject that we used in our RosterViewModel for publishing actions.

To allow subscribers to have access to that resultSubject, add this method to Controller:

  public Observable<Result> resultStream() {
    return resultSubject;

Finally, we need to call onNext() on that resultSubject as part of processing each of our actions. So, modify the add(), modify(), and delete() methods to create and emit the associated Result objects:

  private void add(ToDoModel model) {

  private void modify(ToDoModel model) {

  private void delete(ToDoModel toDelete) {

Step #2: Mutating the ViewState

The preview of this section is en route to Mars.

Step #3: Reducing the Results

The preview of this section was traded for a bag of magic beans.

Step #4: Publishing the ViewStates

The preview of this section is off trying to sweet-talk the Khaleesi into providing us with a dragon.

Step #5: Handling Modify and Delete Results

The preview of this section is unavailable right now, but if you leave your name and number at the sound of the tone, it might get back to you (BEEEEEEEEEEEEP!).

Step #6: Handling the Initial Load

The preview of this section was the victim of a MITM ('Martian in the middle') attack.

Step #7: Showing Items

The preview of this section apparently resembled a Pokémon.

Step #8: Wrapping Up the Rendering

The preview of this section is in an invisible, microscopic font.

Step #9: Trying It Out

The preview of this section is out seeking fame and fortune as the Dread Pirate Roberts.

What We Changed

The preview of this section was eaten by a grue.