0Pricing
Kotlin Multiplatform Academy · Lesson

Handle User Intents & Actions

Drive state changes from UI events.

The UI Asks, You Decide

When a user taps a button, the UI should not run logic itself. It sends an intent to the ViewModel, which decides what happens.

Name Your Intents

Model each possible user action as a sealed class. Now every intent the screen can fire is named, typed and impossible to misspell.

sealed class HomeIntent {
    object Refresh : HomeIntent()
    data class Search(val q: String) : HomeIntent()
}

All lessons in this course

  1. A Cross-Platform ViewModel Base
  2. Expose UI State as StateFlow
  3. Handle User Intents & Actions
  4. Bind the ViewModel to Each UI
← Back to Kotlin Multiplatform Academy