val drinkAmount: Double, val hydrations: List<HydrationState> ) { val hydrationState: HydrationState val streakState: StreakState val settingsState: SettingsState } sealed class AppAction { object Drink : AppAction() object Reset : AppAction() data class UpdateGoal(val goal: Double) : AppAction() data class UpdateDrinkSize(val drinkSize: Double) : AppAction() } AppDomain.kt
Reducer function S.() → S Makes it nice to update state, just use copy() Reducer functions are queued on a designated dispatcher withState {} • • • • Access the current state (S) → Unit Guaranteed to run after setState queue Functions are queued up on a designated dispatcher as well
• • Square Library by Ray Ryan + Zach Klippenstein Tree of Composable State Machines Core Concepts (IMO) Workflow Workflow Actions View "Stuff" Workers
NEXT? DROIDCON SF 2022 @HEYRIKIN • • • • Renderings are View State State is Internal State Renderings typically wrap out Internal State Renderings forward actions to the Workflows via lambdas
DROIDCON SF 2022 @HEYRIKIN • • • • State Reducers Has access to the current state Respond to events, update state Causes Workflow to render() with updated State
WHAT NEXT? DROIDCON SF 2022 @HEYRIKIN • • • • • Maybe Mavericks might be easier to use Workflow is more comprehensive Building a personal project? Learn from them and build your own
DROIDCON SF 2022 @HEYRIKIN • • • • Mavericks —> Workflow Migration Lot's of code Reuse Can learn a lot source diving these libraries Lot's of other libraries to explore, wanna keep using + updating them