Created
February 8, 2018 15:05
-
-
Save thoretton-edwin/936451ebf7800078127eb0ae612f04df to your computer and use it in GitHub Desktop.
kotlin on subscribe extension
This file contains 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 <T> Observable<T>.subscribe(onNext:(T)-> Unit = {}, context: KFunction<out Unit>? = null) { | |
this.subscribe({}, { ErrorController().onError("[ ${context?.name} ]",it) }) | |
} | |
//exemple | |
private fun onReceiveShareAction(userId: String) { | |
messenger.sendShareMessage(Recipient(userId)).subscribe(context = ::onReceiveShareAction) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment