package Ġcom . blue lin el abs . cond uctor . demo . controllers . base Ċ Ċ import Ġcom . blue lin el abs . cond uctor . Controller Ċ import Ġcom . blue lin el abs . cond uctor . Controller Change Handler Ċ import Ġcom . blue lin el abs . cond uctor . Controller Change Type Ċ import Ġleak can ary . App Watcher Ċ Ċ private Ġclass ĠRef Watch ing Controller Lifecycle Listener Ġ: ĠController . Lifecycle Listener () Ġ{ ĊĊĠ Ġprivate Ġvar Ġhas Exit ed Ġ= Ġfalse ĊĊĠ Ġoverride Ġfun Ġpost Destroy ( controller : ĠController ) Ġ{ ĊĠĠĠ Ġif Ġ( has Exit ed ) Ġ{ ĊĠĠĠĠĠ Ġcontroller . expect Weak ly Reach able () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġoverride Ġfun ĠonChange End ( ĊĠĠĠ Ġcontroller : ĠController , ĊĠĠĠ Ġchange Handler : ĠController Change Handler , ĊĠĠĠ Ġchange Type : ĠController Change Type ĊĠ Ġ) Ġ{ ĊĠĠĠ Ġhas Exit ed Ġ= Ġ! change Type . is Enter ĊĠĠĠ Ġif Ġ( controller . is Destroyed ) Ġ{ ĊĠĠĠĠĠ Ġcontroller . expect Weak ly Reach able () ĊĠĠĠ Ġ} ĊĠ Ġ} ĊĊĠ Ġprivate Ġfun ĠController . expect Weak ly Reach able () Ġ{ ĊĠĠĠ ĠApp Watcher . object Watcher . expect Weak ly Reach able ( ĊĠĠĠĠĠ Ġthis , ĊĠĠĠĠĠ Ġ" A Ġdestroyed Ġcontroller Ġshould Ġhave Ġonly Ġweak Ġreferences ." ĊĠĠĠ Ġ) ĊĠ Ġ} Ċ } Ċ Ċ fun ĠController . watch For Le aks () Ġ{ ĊĠ Ġadd Lifecycle Listener ( Ref Watch ing Controller Lifecycle Listener ()) Ċ } Ċ