package Ġorg . j dc . template . ux . individual Ċ Ċ import Ġandroidx . h ilt . Ass isted Ċ import Ġandroidx . h ilt . lifecycle . ViewModel Inject Ċ import Ġandroidx . lifecycle . Saved State Handle Ċ import Ġandroidx . lifecycle . ViewModel Ċ import Ġandroidx . lifecycle . viewModel Scope Ċ import Ġkotlinx . coroutines . channels . Receive Channel Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . launch Ċ import Ġorg . j dc . template . analytics . Analytics Ċ import Ġorg . j dc . template . coroutine . channel . ViewModel Channel Ċ import Ġorg . j dc . template . deleg ates . require Saved State Ċ import Ġorg . j dc . template . model . db . main . individual . Individual Ċ import Ġorg . j dc . template . model . repository . Individual Repository Ċ Ċ class ĠIndividual ViewModel Ċ @ ViewModel Inject Ġconstructor ( ĊĠĠĠ Ġprivate Ġval Ġanalytics : ĠAnalytics , ĊĠĠĠ Ġprivate Ġval Ġindividual Repository : ĠIndividual Repository , ĊĠĠĠ Ġ@ Ass isted Ġsaved State Handle : ĠSaved State Handle Ċ ) Ġ: ĠViewModel () Ġ{ ĊĠĠĠ Ġprivate Ġval Ġ_ event Channel : ĠViewModel Channel < Event > Ġ= ĠViewModel Channel ( this ) ĊĠĠĠ Ġval Ġevent Channel : ĠReceive Channel < Event > Ġ= Ġ_ event Channel ĊĊĠĠĠ Ġprivate Ġval Ġindividual Id : ĠLong Ġby Ġrequire Saved State ( saved State Handle , Ġ" individual Id ") ĊĠĠĠ Ġval Ġindividual Flow : ĠFlow < Individual > ĊĠĠĠĠĠĠĠ Ġget () Ġ= Ġindividual Repository . get Individual Flow ( individual Id ) ĊĊĠĠĠ Ġinit Ġ{ ĊĠĠĠĠĠĠĠ Ġanalytics . log Event ( Analytics . EVENT _ VIEW _ IN DI VID UAL ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġdelete Individual () Ġ= ĠviewModel Scope . launch Ġ{ ĊĠĠĠĠĠĠĠ Ġanalytics . log Event ( Analytics . EVENT _ DELETE _ IN DI VID UAL ) ĊĠĠĠĠĠĠĠ Ġindividual Repository . delete Individual ( individual Id ) ĊĊĠĠĠĠĠĠĠ Ġ_ event Channel . send Async ( Event . Individual Deleted Event ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġedit Individual () Ġ{ ĊĠĠĠĠĠĠĠ Ġanalytics . log Event ( Analytics . EVENT _ EDIT _ IN DI VID UAL ) ĊĠĠĠĠĠĠĠ Ġ_ event Channel . send Async ( Event . Edit Individual Event ( individual Id )) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġsealed Ġclass ĠEvent Ġ{ ĊĠĠĠĠĠĠĠ Ġdata Ġclass ĠEdit Individual Event ( val Ġindividual Id : ĠLong ) Ġ: ĠEvent () ĊĠĠĠĠĠĠĠ Ġobject ĠIndividual Deleted Event Ġ: ĠEvent () ĊĠĠĠ Ġ} Ċ }