package Ġcom . ig or vd . bitcoin charts . features . charts . presentation . home Ċ Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġcom . ig or vd . bitcoin charts . core . presentation . view . error . Error View Exception Mapper Ċ import Ġcom . ig or vd . bitcoin charts . features . charts . domain . use case . Get Home Stats Screen UseCase Ċ import Ġcom . ig or vd . bitcoin charts . features . charts . presentation . home . model . Home State Ċ 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 Ċ Ċ @ H ilt ViewModel Ċ class ĠChart s Home ViewModel Ġ@ Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġget Home Stats Screen UseCase : ĠGet Home Stats Screen UseCase , ĊĠĠĠ Ġprivate Ġval Ġerror View Exception Mapper : ĠError View Exception Mapper Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ home State Flow Ġ= ĠMutable State Flow < Home State ? >( null ) ĊĠĠĠ Ġval Ġhome State Flow : ĠState Flow < Home State ?> Ġget () Ġ= Ġ_ home State Flow ĊĊĠĠĠ Ġsuspend Ġfun Ġget Home Screen () Ġ{ ĊĠĠĠĠĠĠĠ Ġtry Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ home State Flow . value Ġ= ĠHome State . Loading ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġstats Ġ= Ġget Home Stats Screen UseCase . get () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ home State Flow . value Ġ= ĠHome State . Show Stats ( stats ) ĊĠĠĠĠĠĠĠ Ġ} Ġcatch Ġ( e : ĠException ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ home State Flow . value Ġ= ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠHome State . Show Error ( error View Exception Mapper . map To Error ViewData ( e )) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }