package Ġcom . n ora . ny t news apps . data . repository Ċ Ċ import Ġandroidx . lifecycle . LiveData Ċ import Ġandroidx . lifecycle . Transform ations Ċ import Ġcom . n ora . ny t news apps . data . database . Story Database Ċ import Ġcom . n ora . ny t news apps . data . network . NY T News Api Ċ import Ġcom . n ora . ny t news apps . data . network . Network Story Ċ import Ġcom . n ora . ny t news apps . data . network . as Database Ċ import Ġcom . n ora . ny t news apps . data . network . as Domain Ċ import Ġkotlinx . coroutines . Dispatch ers Ċ import Ġkotlinx . coroutines . with Context Ċ Ċ class ĠToday Repository ( private Ġval Ġdatabase : ĠStory Database ) Ġ{ ĊĊĠĠĠ Ġval Ġstories : ĠLive Data < List < Network Story >> Ġ= ĠTransform ations . map ( database . story Dao . get Saved St ories ()) Ġ{ ĊĠĠĠĠĠĠĠ Ġit . as Domain () ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsuspend Ġfun Ġget Top St ories ( section : ĠString Ġ= Ġ" home ") Ġ{ ĊĠĠĠĠĠĠĠ Ġwith Context ( Dispatch ers . IO ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġtop St ories Ġ= ĠN YT News Api . news Service . get News Today ( section ). await () ĊĠĠĠĠĠĠĠĠĠĠĠ Ġdatabase . story Dao . insert (* top St ories . as Database ()) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} Ċ }