package Ġde . half bit . com achine Ċ Ċ import Ġde . half bit . com achine . dsl . Com achine Block Ċ import Ġde . half bit . com achine . dsl . Com achine Delegate Block Ċ Ċ /** Ċ Ġ* ĠMutable Ġcom achine Ġcan Ġbe Ġextended Ġby Ġfeature Ġspecific Ġlogic Ġencaps ulated Ċ Ġ* Ġin Ġa Ġdelegate . ĠThis Ġcan Ġbe Ġused Ġto Ġde compose Ġcomplex Ġstate Ġmachine Ġinto Ċ Ġ* Ġmultiple Ġmini Ġstate Ġmachines Ġoperating Ġon Ġthe Ġsame Ġstate . Ċ Ġ* Ċ Ġ* ĠFor Ġexample , Ġa Ġcomplex Ġscreen Ġwhere Ġa Ġuser Ġcan Ġperform Ġmultiple Ġactions Ċ Ġ* Ġcan Ġbe Ġsplit Ġinto Ġmultiple Ġdeleg ates Ġresponsible Ġfor Ġa Ġsingle Ġaction . Ċ Ġ* Ċ Ġ* ĠNew Ġdeleg ates Ġcan Ġonly Ġbe Ġadded Ġto Ġa Ġnot Ġyet Ġloop ed Ġmutable Ġcom achine . Ċ Ġ*/ Ċ interface ĠMutable Com achine < State Ġ: ĠAny , ĠEvent Ġ: ĠAny > Ġ: ĠCom achine < State , ĠEvent > Ġ{ ĊĠĠĠ Ġfun Ġregister Delegate ( block : ĠCom achine Delegate Block < State , ĠEvent >. () Ġ-> ĠUnit ) Ċ } Ċ Ċ fun Ġ< State Ġ: ĠAny , ĠEvent Ġ: ĠAny > Ġmutable Com achine ( ĊĠĠĠ Ġstart With : ĠState , ĊĠĠĠ Ġblock : ĠCom achine Block < State , ĠEvent >. () Ġ-> ĠUnit Ġ= Ġ{} Ċ ): ĠMutable Com achine < State , ĠEvent > Ġ= ĊĠĠĠ ĠCom achine Block < State , ĠEvent >( start With ). also ( block ). build () Ċ