Last active
December 27, 2017 04:24
-
-
Save tcw165/3b2346f1584ebe0472707333b3767e40 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
private fun toShareAction(): Observable<ShareProgressState> { | |
// 1. Generate BMP | |
return getGenBmpObservable() | |
// 2. Show dialog | |
.switchMap { _ -> | |
getDialogSingle() | |
.toObservable() | |
} | |
// 3. Share | |
.switchMap { dialogPayload -> | |
if (dialogPayload.result == RESULT_OK) { | |
// If the user clicks OK, share to FB. | |
getShareToFacebookObservable(dialogPayload.data) | |
} else { | |
// The EMPTY observable calls observer's onComplete() | |
// to indicate the stream is over. | |
Observable.empty() | |
} | |
} | |
} | |
/** | |
* Returns a CANCEL action. | |
*/ | |
private fun toCancelAction(): Observable<ShareProgressState> { | |
return Observable.just(ShareProgressState(justStop = true)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment