package Ġco . nim ble hq . coroutine . ui . screens . compose Ċ Ċ import Ġandroidx . compose . runtime . State Ċ import Ġandroidx . compose . runtime . mutable State Of Ċ import Ġco . nim ble hq . coroutine . model . User Ui Model Ċ import Ġco . nim ble hq . coroutine . model . to User Ui Models Ċ import Ġco . nim ble hq . coroutine . ui . base . Base ViewModel Ċ import Ġco . nim ble hq . coroutine . domain . use case . Get Users UseCase Ċ import Ġco . nim ble hq . coroutine . domain . use case . UseCase Result Ċ import Ġco . nim ble hq . coroutine . util . Dispatch ers Provider Ċ import Ġdagger . h ilt . android . lifecycle . H ilt ViewModel Ċ import Ġkotlinx . coroutines . flow . Mutable State Flow Ċ import Ġkotlinx . coroutines . flow . State Flow Ċ import Ġjavax . inject . Inject Ċ Ċ interface ĠOutput Ġ{ ĊĊĠĠĠ Ġval Ġuser Ui Models : ĠState Flow < List < User Ui Model >> ĊĊĠĠĠ Ġval Ġtext FieldValue : ĠState < String > ĊĊĠĠĠ Ġfun Ġupdate TextField Value ( value : ĠString ) Ċ } Ċ Ċ @ H ilt ViewModel Ċ class ĠCompose ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġget Users UseCase : ĠGet Users UseCase , ĊĠĠĠ Ġdispatch ers : ĠDispatch ers Provider Ċ ) Ġ: ĠBase ViewModel ( dispatch ers ), ĠOutput Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ user Ui Models Ġ= ĠMutable State Flow < List < User Ui Model >>( emptyList ()) ĊĠĠĠ Ġoverride Ġval Ġuser Ui Models : ĠState Flow < List < User Ui Model >> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ user Ui Models ĊĊĠĠĠ Ġprivate Ġval Ġ_ text FieldValue Ġ= Ġmutable State Of ("") ĊĠĠĠ Ġoverride Ġval Ġtext FieldValue : ĠState < String > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ text FieldValue ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġfetch Users () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġoverride Ġfun Ġupdate TextField Value ( value : ĠString ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ_ text FieldValue . value Ġ= Ġvalue ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġfetch Users () Ġ{ ĊĠĠĠĠĠĠĠ Ġshow Loading () ĊĠĠĠĠĠĠĠ Ġexecute Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġwhen Ġ( val Ġresult Ġ= Ġget Users UseCase . execute ()) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠUse Case Result . Success Ġ-> Ġ_ user Ui Models . value Ġ= Ġresult . data . to User Ui Models () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġis ĠUse Case Result . Error Ġ-> Ġ_ error . emit ( result . exception . message . or Empty ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠĠĠĠĠ Ġhide Loading () ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ } Ċ