~/talk

State holders and state production in the UI Layer

Talkat Android Dev Summit 2022 · 2022-10-24..11-14· [android]
slides:none on file

Recommendation: use a ViewModel as the screen-level state holder to keep business logic and screen UI state, use viewModelScope for long-running requests and to survive configuration changes, and avoid holding Context or passing ViewModels around. Use plain state holder classes for reusable UI element logic (example: DrawerState delegating to swipeableState). Produce UI state with MutableStateFlow/StateFlow, use combine() to merge local and external streams and stateIn(viewModelScope, WhileSubscribed, 5 seconds), then collect with collectAsStateWithLifecycle.

AI-written summary · about

  1. 0:00Introduction
  2. 1:37Types of UI state
  3. 2:24Types of logic
  4. 4:25How state and logic relate to each other
  5. 4:50Where to handle logic
  6. 5:10ViewModels
  7. 8:55Plain state holder classes
  8. 11:35Identifying state holders in the UI
  9. 13:08Should you use ViewModels?
  10. 14:20Producing screen UI state
  11. 15:03Local sources of state change
  12. 16:07External sources of state change
  13. 16:56Combining local and external sources
  14. 18:15Collect state in a lifecycle-aware manner
  15. 18:40Modelling screen UI state based on inputs
  16. 19:34Recap
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.