package Ġcom . y vk al ume . y ooks . ui . preview Ċ Ċ import Ġcom . air bnb . mv rx . M aver icks ViewModel Ċ import Ġcom . y vk al ume . model . domain . Book Ċ import Ġcom . y vk al ume . model . presentation . Preview Data Ċ import Ġkotlinx . coroutines . flow . map Ċ import Ġkotlinx . coroutines . launch Ċ import Ġorg . k oin . core . K oin Component Ċ import Ġorg . k oin . core . inject Ċ Ċ class ĠPreview ViewModel ( initialState : ĠPreview ViewState ) Ġ: ĠM aver icks ViewModel < Preview ViewState >( initialState ), ĠK oin Component Ġ{ ĊĠĠĠ Ġprivate Ġval Ġpresenter : ĠPreview Presenter Ġby Ġinject () ĊĠĠĠ Ġfun Ġload ( uid : ĠString ) Ġ= ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . get Book By Uid ( uid ). map Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ ĠPreview Data ( book Ġ= Ġit ) ĊĠĠĠĠĠĠĠ Ġ}. execute Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcopy ( preview Data Ġ= Ġit ) ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġpresenter . is Favorite ( uid ). execute Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġcopy ( is Favorite Ġ= Ġit ) ĊĠĠĠĠĠĠĠ Ġ} ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun ĠaddTo Favorite ( book : ĠBook ) Ġ Ġ= ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . addTo F avorites ( book ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġremove Book From Favorite ( book Uid : ĠString ) Ġ= ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠ Ġpresenter . remove Book From Favorite ( book Uid ) ĊĠĠĠ Ġ} Ċ }