Architecture

Events

So how do we make changes? That's where events come in.

The user interface receives user interactions, such as key and button presses, and interprets their meaning. It then calls Event functions to trigger state changes.

When using Jetpack Compose, these event functions are typically Kotlin lambdas passed into the functions we use to create the user interface. Most of these lambdas will call functions in the view model; others may update some local state in the user interface itself.

flowchart LR
    subgraph User Interface Layer
    ui[User Interface] -->|"event()"| vm[View Model]
    end
    vm -->|"update()"| repo
    ds -->|query| db[(Database)]
    subgraph Data Layer
    repo[Repository] -->|"update()"| ds[Data Source]
    end
flowchart LR
    subgraph User Interface Layer
    ui[User Interface] -->|"event()"| vm[View Model]
    end
    vm -->|"update()"| uc
    uc -->|"update()"| repo
    ds -->|query| db[(Database)]
    subgraph Domain Layer
    direction TB
    data[Data]
    uc[Use Case]
    end
    subgraph Data Layer
    repo[Repository] -->|"update()"| ds[Data Source]
    end

We'll see how this works when we start coding our user interface.