Last active
August 6, 2019 16:41
-
-
Save SeongUgJung/dc6050875a904015843df2e3dbc6cf79 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
typealias DisposableFunction = () -> Disposable // e.g) Observable.just().subscrbie() | |
class RxLifecycle : LifecycleObserver { | |
private var onInit: DisposableFunction? = null | |
private var initDisposable: Disposable? = null | |
override fun onInit() { | |
// create 시점에 Stream 실행 | |
initDisposable = this.onInit?.invoke() | |
} | |
override fun onDeinit() { | |
// destroy 시 실행된 stream 종료 | |
if (initDisposable?.isDisposed == false) { | |
initDisposable?.dispose() | |
} | |
} | |
fun onVisible() | |
fun onInvisible() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment