package Ġcom . d roid con . speak ers . presentation . speaker list . view model Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Mutable LiveData Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġcom . d roid con . commons . lifecycle . Single Live Event Ċ import Ġcom . d roid con . commons . tracking . S peak ers Tracker Ċ import Ġcom . d roid con . speak ers . domain . GetAll S peak ers Ċ import Ġcom . d roid con . speak ers . domain . Speaker Ċ import Ġcom . d roid con . speak ers . presentation . speaker list . model . Speaker State Ċ import Ġcom . d roid con . speak ers . presentation . speaker list . model . S peak ers Effect Ċ import Ġcom . d roid con . speak ers . presentation . speaker list . model . S peak ers State Ċ import Ġcom . d roid con . speak ers . presentation . speaker list . model . to State Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠS peak ers ViewModel ( ĊĠĠĠ Ġprivate Ġval ĠgetAll S peak ers : ĠGetAll S peak ers , ĊĠĠĠ Ġprivate Ġval Ġspeak ers Tracker : ĠS peak ers Tracker Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġmutable S peak ers State Ġ= ĠMutable LiveData < S peak ers State >() ĊĠĠĠ Ġval Ġspeak ers State : ĠLive Data < S peak ers State > Ġ= Ġmutable S peak ers State ĊĊĠĠĠ Ġprivate Ġval Ġmutable S peak ers Effects Ġ= ĠSingle Live Event < S peak ers Effect >() ĊĠĠĠ Ġval Ġspeak ers Effects : ĠLive Data < S peak ers Effect > Ġ= Ġmutable S peak ers Effects ĊĊĠĠĠ Ġfun Ġon S peak ers Screen Visible () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠgetAll S peak ers (). fold ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Left Ġ= Ġ{ Ġon GetAll S peak ers Error () Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Right Ġ= Ġ:: on GetAll S peak ers Success ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġon Search T apped () Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable S peak ers Effects . setValue ( S peak ers Effect . Navigate To Search ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon GetAll S peak ers Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable S peak ers State . value Ġ= ĠS peak ers State . Error ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon GetAll S peak ers Success ( speak ers : ĠList < Speaker >) Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable S peak ers State . value Ġ= Ġspeak ers . to State (:: on Speaker T apped ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon Speaker T apped ( speaker : ĠS peaker State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable S peak ers Effects . setValue ( S peak ers Effect . Navigate To Detail ( speaker . id )) ĊĠĠĠĠĠĠĠ Ġspeak ers Tracker . track Speaker Opened ( speaker . title ) ĊĠĠĠ Ġ} Ċ }