package Ġcom . d roid con . speak ers . presentation . speaker search . 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 . Search 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 search . model . S peak ers Search Effect Ċ import Ġcom . d roid con . speak ers . presentation . speaker search . model . S peak ers SearchResult Ċ import Ġcom . d roid con . speak ers . presentation . speaker search . model . to S peak ers SearchResult Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠSearch S peak ers ViewModel ( ĊĠĠĠ Ġprivate Ġval Ġsearch S peak ers : ĠSearch S peak ers , ĊĠĠĠ Ġprivate Ġval Ġspeak ers Tracker : ĠS peak ers Tracker Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġmutable S peak ers Search Effect Ġ= ĠSingle Live Event < S peak ers Search Effect >() ĊĠĠĠ Ġval Ġspeak ers Search Effect : ĠLive Data < S peak ers Search Effect > Ġ= Ġmutable S peak ers Search Effect ĊĊĠĠĠ Ġprivate Ġval Ġmutable S peak ers SearchResult Ġ= ĠMutable LiveData < S peak ers SearchResult >() ĊĠĠĠ Ġval Ġspeak ers SearchResult : ĠLive Data < S peak ers SearchResult > Ġ= Ġmutable S peak ers SearchResult ĊĊĠĠĠ Ġfun Ġon Search Query Changed ( query Text : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġif Ġ( query Text . isBlank ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġmutable S peak ers SearchResult . value Ġ= ĠS peak ers SearchResult . Empty ĊĠĠĠĠĠĠĠĠĠĠĠ Ġreturn ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġspeak ers Ġ= Ġsearch S peak ers ( query Text ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġspeak ers . fold ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Left Ġ= Ġ{ Ġon S peak ers Search Error () Ġ}, ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġif Right Ġ= Ġ:: on S peak ers SearchResult Received ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon S peak ers SearchResult Received ( speak ers : ĠList < Speaker >) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġspeak ers SearchResult Ġ= Ġspeak ers . to S peak ers SearchResult (:: on Speaker T apped ) ĊĠĠĠĠĠĠĠ Ġmutable S peak ers SearchResult . value Ġ= Ġspeak ers SearchResult ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon S peak ers Search Error () Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable S peak ers SearchResult . value Ġ= ĠS peak ers SearchResult . Error ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġon Speaker T apped ( speaker : ĠS peaker State ) Ġ{ ĊĠĠĠĠĠĠĠ Ġmutable S peak ers Search Effect . setValue ( S peak ers Search Effect . Navigate ToS peaker Detail ( speaker . id )) ĊĠĠĠĠĠĠĠ Ġspeak ers Tracker . track Speaker Opened From Search ( speaker . title ) ĊĠĠĠ Ġ} Ċ }