Last active
August 6, 2019 16:46
-
-
Save SeongUgJung/880cdd6d72f0c4fc45b10a6370c701ce to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 기존 | |
lifecycleController.addObserver(onInit { Observable.create().subscribe() }) | |
// 코드 추가 | |
interface LifecycleDelegate { operator fun LifecycleObserver.unaryPlus() } | |
class LifecycleController : LifecycleDelegate { | |
fun LifecycleObserver.unaryPlus() { | |
[email protected] += this | |
} | |
} | |
// 변경 후 | |
+onInit { Observable.create().subscribe() } | |
// 실제 모습 | |
class MainViewModel(delegate: LifecycleDelegate) : LifecycleDelegate by delegate { | |
init { | |
+onInit { Observable.create().subscribe() } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment