What problem does it solve?
This guide helps Amethyst developers apply advanced Kotlin idioms—StateFlow/SharedFlow for robust state and event handling, sealed hierarchies for exhaustive modeling, @Immutable-based Compose optimization, DSL builders for readable APIs, and inline/reified patterns for performance—across multiplatform codebases.
Core Features & Use Cases
- State management patterns with StateFlow/SharedFlow to model UI state and events in a scalable way.
- Sealed hierarchies (sealed classes and sealed interfaces) to model distinct UI states and generic results with exhaustiveness.
- Immutability and Compose performance practices using @Immutable, data classes, and kotlinx.collections.immutable.
- DSL builders and type-safe DSLs to build domain objects and configurations succinctly.
- Inline and reified patterns to reduce allocation and enable runtime type checks in hot paths.
Quick Start
Create a tiny Kotlin module that demonstrates a StateFlow-based UI state, a sealed class for view states, and an immutable data class, then observe updates in a simple Compose-like flow.