~/talk

ViewModels, LiveData and Lifecycles, oh my!

Talkat droidcon NYC 2017 · 2017-09-25..09-26· [android]
slides:none on file

Practical demo of Android Architecture Components: uses ViewModel + LiveData + Lifecycle to move UI state out of Activities (example: Court Counter) so data survives rotations via ViewModelProvider and retained fragments, shows MutableLiveData vs LiveData with setValue/postValue, uses Transformations.map for formatting and switchMap to swap underlying LiveData for a search app backed by a repository (Room suggested). Notes ViewModel dies on process-kill and recommends saving minimal keys in savedInstanceState and persisting heavier data in a database.

AI-written summary · about

  1. 0:00Introduction to architecture
  2. 4:27Redesigning Court Counter
  3. 10:45ViewModel lifecycle explained
  4. 15:40Passing values to ViewModel
  5. 16:03LiveData lifecycle awareness
  6. 19:34Transforming LiveData with map
  7. 23:50LiveData recap and MutableLiveData
  8. 25:15Introducing repository pattern
  9. 27:20Naive search implementation
  10. 29:27Using switchMap for searches
  11. 35:25Recap of repository and LiveData
  12. 35:47Persisting UI state after process death
~/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.