Controllers

Controllers are the middleman between View and Model. They contain the convenience functions, such as performing basic HTTP operations such as GET, PUT, POST, and DELETE. They add an abstraction layer and help separate the networking logic from our business logic or the UI logic. 

Here, we have a WordController class that contains a function named getMeaning, which sends a GET request to the Words API in order to get the meaning of the specified word, and on a success, it receives a response that the REST client internally converts to a domain model object; otherwise, else it returns null:

    /**     * Abstraction layer to perform HTTP operations     */    class WordController : Controller() {      private val api: Rest by inject()      /** * Sends ...

Get Kotlin Blueprints 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.