/* Ċ Ġ* ĠCreated Ġby ĠKar ic ĠKen an Ġon Ġ 2 1 . 4 . 2 0 2 1 Ċ Ġ* ĠCopyright Ġ( c ) Ġ 2 0 2 1 Ġ. ĠAll Ġrights Ġreserved . Ċ Ġ*/ Ċ Ċ package Ġio . ae thi bo . fork . ui . notifications . view model Ċ Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġio . ae thi bo . data . utils . Resource Ċ import Ġio . ae thi bo . domain . response . Notification Response Ċ import Ġio . ae thi bo . use cases . Get Notifications UseCase Ċ import Ġkotlinx . coroutines . Coroutine Dispatcher Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . flow . Mutable State Flow Ċ import Ġkotlinx . coroutines . flow . State Flow Ċ import Ġkotlinx . coroutines . launch Ċ Ċ class ĠNotifications ViewModel ( ĊĠĠĠ Ġprivate Ġval Ġget Notifications : ĠGet Notifications UseCase , ĊĠĠĠ Ġprivate Ġval Ġdispatcher : ĠCor outine Dispatcher Ġ= ĠDispatch ers . Main Ċ ) Ġ: ĠViewModel () Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġ_ notifications Status : ĠMutable State Flow < Resource < List < Notification Response >>> Ġ= ĊĠĠĠĠĠĠĠ ĠMutable State Flow ( Resource . Loading ()) ĊĠĠĠ Ġval Ġnotifications Status : ĠState Flow < Resource < List < Notification Response >>> ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġ_ notifications Status ĊĊĠĠĠ Ġfun Ġget Notifications () Ġ{ ĊĠĠĠĠĠĠĠ ĠviewModel Scope . launch ( dispatcher ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġresult : ĠResource < List < Notification Response >> Ġ= Ġget Notifications . invoke () ĊĊĠĠĠĠĠĠĠĠĠĠĠ Ġ_ notifications Status . value Ġ= Ġresult ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }