/* Ċ Ġ* ĠCopyright Ġ( C ) Ġ 2 0 2 1 ĠR ick ĠBus ar ow Ċ Ġ* ĠLicensed Ġunder Ġthe ĠApache ĠLicense , ĠVersion Ġ 2 . 0 Ġ( the Ġ" License "); Ċ Ġ* Ġyou Ġmay Ġnot Ġuse Ġthis Ġfile Ġexcept Ġin Ġcompliance Ġwith Ġthe ĠLicense . Ċ Ġ* ĠYou Ġmay Ġobtain Ġa Ġcopy Ġof Ġthe ĠLicense Ġat Ċ Ġ* Ċ Ġ* ĠĠĠĠĠ Ġhttp :// www . apache . org / licenses / LICENSE - 2 . 0 Ċ Ġ* Ċ Ġ* ĠUnless Ġrequired Ġby Ġapplicable Ġlaw Ġor Ġagreed Ġto Ġin Ġwriting , Ġsoftware Ċ Ġ* Ġdistributed Ġunder Ġthe ĠLicense Ġis Ġdistributed Ġon Ġan Ġ" AS ĠIS " ĠBASIS , Ċ Ġ* ĠWITHOUT ĠWARRANTIES ĠOR ĠCONDITIONS ĠOF ĠANY ĠKIND , Ġeither Ġexpress Ġor Ġimplied . Ċ Ġ* ĠSee Ġthe ĠLicense Ġfor Ġthe Ġspecific Ġlanguage Ġgoverning Ġpermissions Ġand Ċ Ġ* Ġlimitations Ġunder Ġthe ĠLicense . Ċ Ġ*/ Ċ Ċ package Ġdispatch . android . lifecycle Ċ Ċ import Ġandroidx . lifecycle .* Ċ import Ġdispatch . android . lifecycle . internal .* Ċ import Ġkotlinx . coroutines .* Ċ import Ġkotlin . coroutines .* Ċ Ċ /** Ċ Ġ* ĠExec utes Ġ` block ` Ġone Ġtime , Ġthe Ġnext Ġtime Ġthe Ġ[ Lifecycle ]' s Ġstate Ġis Ġat Ġleast Ġ[ Lifecycle . State . CREATED ]. Ċ Ġ* Ċ Ġ* ĠIf Ġthe Ġlifecycle Ġis Ġalready Ġin Ġthis Ġstate , Ġ` block ` Ġwill Ġbe Ġexecuted Ġimmediately . Ċ Ġ* Ċ Ġ* Ġ@ see Ġ[ Dispatch Lifecycle Scope . launch On Create ] Ġfor Ġrepe ating Ġbehavior . Ċ Ġ* Ġ@ param Ġcontext Ġ* optional * Ġ- Ġadditional Ġto Ġ[ Coroutine Scope . coroutine Context ] Ġcontext Ġof Ġthe Ġcoroutine . Ċ Ġ* Ġ@ sample Ġdispatch . android . lifecycle . samples . Lifecycle Suspend Sample . lifecycle Owner On Next Create Sample Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > ĠLifecycle Owner . onNext Create ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠT ? Ġ= Ġlifecycle . onNext ( context , ĠLifecycle . State . CREATED , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠExec utes Ġ` block ` Ġone Ġtime , Ġthe Ġnext Ġtime Ġthe Ġ[ Lifecycle ]' s Ġstate Ġis Ġat Ġleast Ġ[ Lifecycle . State . CREATED ]. Ċ Ġ* Ċ Ġ* ĠIf Ġthe Ġlifecycle Ġis Ġalready Ġin Ġthis Ġstate , Ġ` block ` Ġwill Ġbe Ġexecuted Ġimmediately . Ċ Ġ* Ċ Ġ* Ġ@ see Ġ[ Dispatch Lifecycle Scope . launch On Create ] Ġfor Ġrepe ating Ġbehavior . Ċ Ġ* Ġ@ param Ġcontext Ġ* optional * Ġ- Ġadditional Ġto Ġ[ Coroutine Scope . coroutine Context ] Ġcontext Ġof Ġthe Ġcoroutine . Ċ Ġ* Ġ@ sample Ġdispatch . android . lifecycle . samples . Lifecycle Suspend Sample . lifecycle On Next Create Sample Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > ĠLifecycle . onNext Create ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠT ? Ġ= Ġon Next ( context , ĠLifecycle . State . CREATED , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠExec utes Ġ` block ` Ġone Ġtime , Ġthe Ġnext Ġtime Ġthe Ġ[ Lifecycle ]' s Ġstate Ġis Ġat Ġleast Ġ[ Lifecycle . State . STARTED ]. Ċ Ġ* Ċ Ġ* ĠIf Ġthe Ġlifecycle Ġis Ġalready Ġin Ġthis Ġstate , Ġ` block ` Ġwill Ġbe Ġexecuted Ġimmediately . Ċ Ġ* Ċ Ġ* Ġ@ see Ġ[ Dispatch Lifecycle Scope . launch On Start ] Ġfor Ġrepe ating Ġbehavior . Ċ Ġ* Ġ@ param Ġcontext Ġ* optional * Ġ- Ġadditional Ġto Ġ[ Coroutine Scope . coroutine Context ] Ġcontext Ġof Ġthe Ġcoroutine . Ċ Ġ* Ġ@ sample Ġdispatch . android . lifecycle . samples . Lifecycle Suspend Sample . lifecycle Owner On Next Start Sample Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > ĠLifecycle Owner . onNext Start ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠT ? Ġ= Ġlifecycle . onNext ( context , ĠLifecycle . State . STARTED , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠExec utes Ġ` block ` Ġone Ġtime , Ġthe Ġnext Ġtime Ġthe Ġ[ Lifecycle ]' s Ġstate Ġis Ġat Ġleast Ġ[ Lifecycle . State . STARTED ]. Ċ Ġ* Ċ Ġ* ĠIf Ġthe Ġlifecycle Ġis Ġalready Ġin Ġthis Ġstate , Ġ` block ` Ġwill Ġbe Ġexecuted Ġimmediately . Ċ Ġ* Ċ Ġ* Ġ@ see Ġ[ Dispatch Lifecycle Scope . launch On Start ] Ġfor Ġrepe ating Ġbehavior . Ċ Ġ* Ġ@ param Ġcontext Ġ* optional * Ġ- Ġadditional Ġto Ġ[ Coroutine Scope . coroutine Context ] Ġcontext Ġof Ġthe Ġcoroutine . Ċ Ġ* Ġ@ sample Ġdispatch . android . lifecycle . samples . Lifecycle Suspend Sample . lifecycle On Next Start Sample Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > ĠLifecycle . onNext Start ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠT ? Ġ= Ġon Next ( context , ĠLifecycle . State . STARTED , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠExec utes Ġ` block ` Ġone Ġtime , Ġthe Ġnext Ġtime Ġthe Ġ[ Lifecycle ]' s Ġstate Ġis Ġat Ġleast Ġ[ Lifecycle . State . RE SU MED ]. Ċ Ġ* Ċ Ġ* ĠIf Ġthe Ġlifecycle Ġis Ġalready Ġin Ġthis Ġstate , Ġ` block ` Ġwill Ġbe Ġexecuted Ġimmediately . Ċ Ġ* Ċ Ġ* Ġ@ see Ġ[ Dispatch Lifecycle Scope . launch On Resume ] Ġfor Ġrepe ating Ġbehavior . Ċ Ġ* Ġ@ param Ġcontext Ġ* optional * Ġ- Ġadditional Ġto Ġ[ Coroutine Scope . coroutine Context ] Ġcontext Ġof Ġthe Ġcoroutine . Ċ Ġ* Ġ@ sample Ġdispatch . android . lifecycle . samples . Lifecycle Suspend Sample . lifecycle Owner On Next Resume Sample Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > ĠLifecycle Owner . onNext Resume ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠT ? Ġ= Ġlifecycle . onNext ( context , ĠLifecycle . State . RE SU MED , Ġblock ) Ċ Ċ /** Ċ Ġ* ĠExec utes Ġ` block ` Ġone Ġtime , Ġthe Ġnext Ġtime Ġthe Ġ[ Lifecycle ]' s Ġstate Ġis Ġat Ġleast Ġ[ Lifecycle . State . RE SU MED ]. Ċ Ġ* Ċ Ġ* ĠIf Ġthe Ġlifecycle Ġis Ġalready Ġin Ġthis Ġstate , Ġ` block ` Ġwill Ġbe Ġexecuted Ġimmediately . Ċ Ġ* Ċ Ġ* Ġ@ see Ġ[ Dispatch Lifecycle Scope . launch On Resume ] Ġfor Ġrepe ating Ġbehavior . Ċ Ġ* Ġ@ param Ġcontext Ġ* optional * Ġ- Ġadditional Ġto Ġ[ Coroutine Scope . coroutine Context ] Ġcontext Ġof Ġthe Ġcoroutine . Ċ Ġ* Ġ@ sample Ġdispatch . android . lifecycle . samples . Lifecycle Suspend Sample . lifecycle On Next Resume Sample Ċ Ġ*/ Ċ suspend Ġfun Ġ< T > ĠLifecycle . onNext Resume ( ĊĠ Ġcontext : ĠCor outine Context Ġ= ĠEmpty Coroutine Context , ĊĠ Ġblock : Ġsuspend ĠCor outine Scope . () Ġ-> ĠT Ċ ): ĠT ? Ġ= Ġon Next ( context , ĠLifecycle . State . RE SU MED , Ġblock ) Ċ