package Ġcom . soft cube . re _ reddit . common Ċ Ċ import Ġandroidx . lifecycle .* Ċ Ċ /** Ċ Ġ* Ġcom . soft cube . re _ reddit . common Ċ Ġ* Ċ Ġ* ĠCreated Ġby ĠWil son ĠG arc ia Ġon Ġ 6 / 5 / 2 1 Ċ Ġ* ĠCopyright ĠÂ© Ġ 2 0 2 1 ĠWil son ĠG arc ia . ĠAll Ġrights Ġreserved . Ċ Ġ*/ Ċ internal Ġclass ĠOne Time Observer < T >( private Ġval Ġhandler : Ġ( T ) Ġ-> ĠUnit ) Ġ: ĠObserver < T >, ĠLifecycle Owner Ġ{ ĊĊ ĉ private Ġval Ġlifecycle Ġ= ĠLifecycle Registry ( this ) ĊĊ ĉ init Ġ{ Ċĉ ĉ lifecycle . handle Lifecycle Event ( Lifecycle . Event . ON _ RE SU ME ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġget Lifecycle (): ĠLifecycle Ġ= Ġlifecycle ĊĊ ĉ override Ġfun ĠonChanged ( t : ĠT ) Ġ{ Ċĉ ĉ handler ( t ) Ċĉ ĉ lifecycle . handle Lifecycle Event ( Lifecycle . Event . ON _ DESTROY ) Ċ ĉ } Ċ } Ċ Ċ fun Ġ< T > ĠLive Data < T >. observe Once ( onChange Handler : Ġ( T ) Ġ-> ĠUnit ) Ġ{ Ċ ĉ val Ġobserver Ġ= ĠOne Time Observer ( onChange Handler ) Ċ ĉ // ĠLifecycle Ġowner Ġand Ġobserver Ċ ĉ observe ( observer , Ġobserver ) Ċ } Ċ