Creating the login presenter

A presenter, as we saw in Chapter 3, Implementing Tetris Logic and Functionality, is the middleman between a view and a model. It is necessary to create suitable presenters for views to properly facilitate clean view-model interactions. Creating a presenter is fairly easy. We need to first create an interface that properly declares the behaviors that will be exhibited by the presenter. Create a LoginPresenter interface in the login package with the following code:

package com.example.messenger.ui.logininterface LoginPresenter {  fun executeLogin(username: String, password: String)}

As can be easily seen in the preceding code snippet, we want a class that acts as a LoginPresenter for a LoginView to possess an

Get Kotlin Programming By Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.