Skip to content

Instantly share code, notes, and snippets.

@tcw165
Last active December 27, 2017 04:24
Show Gist options
  • Save tcw165/3b2346f1584ebe0472707333b3767e40 to your computer and use it in GitHub Desktop.
Save tcw165/3b2346f1584ebe0472707333b3767e40 to your computer and use it in GitHub Desktop.
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