Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // 기존
- lifecycleController.addObserver(onInit { Observable.create().subscribe() })
- // 코드 추가
- interface LifecycleDelegate { operator fun LifecycleObserver.unaryPlus() }
- class LifecycleController : LifecycleDelegate {
- fun LifecycleObserver.unaryPlus() {
- this@LifecycleController.observers += this
- }
- }
- // 변경 후
- +onInit { Observable.create().subscribe() }
- // 실제 모습
- class MainViewModel(delegate: LifecycleDelegate) : LifecycleDelegate by delegate {
- init {
- +onInit { Observable.create().subscribe() }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement