Uber RIBs Architecture -Part 3

Create Interactor and Router

Mohit Sharma
2 min readJun 18, 2023

All parts in this series.

Part 1: Introduction to RIBs
Part 2:
Creation of View for logged out RIB

Part 3: Creation of Router and Interactor for logged out RIB

Part 4: Creation of Builder for logged out RIB

Part 5: Integrating Builder, Router and Interactor for logged out RIB

In this part we will create LoggedOutInteractor and LoggedOutRouter for out Logged out RIB.

If you have not read the previous part, I would suggest you to go through them first.

Time to write some code.

Create an empty class LoggedOutInteractor and LoggedOutRouter

class LoggedOutInteractor {

}
class LoggedOutRouter()  {

}

Now we will extend our LoggedOutInteractor with Interactor<P,R> which is base interactor for all the interactor in RIBs. P and R are Presenter and Router. We will create an empty Presenter inside LoggedOutInteractor.

We will use this Presenter and LoggedOutRouter as a type for P and R.

Our LoggedOutInteractor code now looks like this.

import com.uber.rib.core.Interactor
import com.uber.rib.core.Presenter

class LoggedOutInteractor: Interactor<LoggedOutInteractor.Presenter, LoggedOutRouter>() {

interface Presenter {}
}

At this moment we will see below error.

Our LoggedOutRouter is not derived from Router class of RIB.
Lets extend our LoggedOutRouter with ViewRouter<V,I>, where V=View and I=Interactor.
Here, note that we have used ViewRouter. It is used when we have a RIB with UI.

We will use LoggedOutView and LoggedOutInteractor for V and I.

Our LoggedOutRouter now looks like this.

import com.uber.rib.core.InteractorBaseComponent
import com.uber.rib.core.ViewRouter

class LoggedOutRouter(
view: LoggedOutView,
interactor: LoggedOutInteractor,
component: InteractorBaseComponent<*>
) : ViewRouter<LoggedOutView, LoggedOutInteractor>(view, interactor, component) {

}

Constructor parameter of view, interactor and component can be auto completed, as those are require by ViewRouter class.

Now we have LoggedOutView, LoggedOutRouter and LoggedOutInteractor for our logged out RIB.

We will cover the builder in next part.

All parts in this series.

Part 1: Introduction to RIBs
Part 2:
Creation of View for logged out RIB

Part 3: Creation of Router and Interactor for logged out RIB

Part 4: Creation of Builder for logged out RIB

Part 5: Integrating Builder, Router and Interactor for logged out RIB

--

--