Last active
June 24, 2018 04:50
-
-
Save tcw165/17ca5aa310d37235a62ee16b7cd390e2 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
| // Activity or Fragment | |
| private val mResumeSignal = PublishSubject.create<Boolean>() | |
| private val mResultSignal = PublishSubject.create<Any>() | |
| override void onResume() { | |
| super.onResume(); | |
| mResumeSignal.onNext(true); | |
| } | |
| override void onPause() { | |
| super.onPause(); | |
| mResumeSignal.onNext(false); | |
| } | |
| override void onActivityResult(requestCode: Int, | |
| resultCode: Int, | |
| data: Intent) { | |
| mResultSignal.onNext(...); | |
| } | |
| // Postpone the moment of sending the result to your Presenter or domain | |
| // component regardless of handling save-restore | |
| fun onGetResult(): Observable<Any> { | |
| return TakeWhenObservable(src = mResultSignal, | |
| whenSrc = mResumeSignal, | |
| bufferSize = 1) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment