SHARE
TWEET

Untitled

a guest Aug 18th, 2019 60 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // 기존
  2. lifecycleController.addObserver(onInit { Observable.create().subscribe() })
  3.  
  4. // 코드 추가
  5. interface LifecycleDelegate { operator fun LifecycleObserver.unaryPlus() }
  6. class LifecycleController : LifecycleDelegate {
  7.   fun LifecycleObserver.unaryPlus() {
  8.     this@LifecycleController.observers += this
  9.   }
  10. }
  11.  
  12. // 변경 후
  13. +onInit { Observable.create().subscribe() }
  14.  
  15. // 실제 모습
  16. class MainViewModel(delegate: LifecycleDelegate) : LifecycleDelegate by delegate {
  17.   init {
  18.     +onInit { Observable.create().subscribe() }
  19.   }
  20. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top