package Ġdev . j im my mor ales . m vi android template . m vi . events Ċ Ċ import Ġdev . j im my mor ales . m vi android template . m vi . UI Event Ċ import Ġkotlinx . coroutines . flow . Flow Ċ import Ġkotlinx . coroutines . flow . Mutable Shared Flow Ċ import Ġkotlinx . coroutines . flow . as Shared Flow Ċ import Ġkotlinx . coroutines . flow . map NotNull Ċ Ċ interface ĠView Event Producer < EVENT Ġ: ĠUI Event > Ġ: ĠView Event Flow < EVENT > Ġ{ ĊĠĠĠ Ġsuspend Ġfun Ġtrigger Event ( event : ĠEVENT ) Ċ } Ċ Ċ /** Ċ Ġ* ĠDefault Ġimplementation Ġof Ġa Ġ[ View Event Producer ]. ĠIt Ġwill Ġmake Ġsure Ġthe Ġevents Ġpropag ated Ġonly Ċ Ġ* Ġonce Ġto Ġthe Ġsubscribers . Ċ Ġ*/ Ċ internal Ġclass ĠCon sum able Event Producer Impl < EVENT Ġ: ĠUI Event > Ġ: ĠView Event Producer < EVENT > Ġ{ ĊĊĠĠĠ Ġprivate Ġval Ġinternal Events Ġ= ĠMutable Shared Flow < Consum able Event < EVENT >>( extra Buffer Capacity Ġ= Ġ 6 4 ) ĊĊĠĠĠ Ġoverride Ġval Ġevents : ĠFlow < EVENT > Ġ= Ġinternal Events ĊĠĠĠĠĠĠĠ Ġ. as Shared Flow () ĊĠĠĠĠĠĠĠ Ġ. map NotNull Ġ{ Ġevent Ġ-> Ġevent . getContent IfNot Handled () Ġ} ĊĊĠĠĠ Ġoverride Ġsuspend Ġfun Ġtrigger Event ( event : ĠEVENT ) Ġ{ ĊĠĠĠĠĠĠĠ Ġinternal Events . emit ( Consum able Event ( event )) ĊĠĠĠ Ġ} Ċ } Ċ