Nothing Special   »   [go: up one dir, main page]

Skip to content

Instantly share code, notes, and snippets.

@thoretton-edwin
Created February 8, 2018 15:05
Show Gist options
  • Save thoretton-edwin/936451ebf7800078127eb0ae612f04df to your computer and use it in GitHub Desktop.
Save thoretton-edwin/936451ebf7800078127eb0ae612f04df to your computer and use it in GitHub Desktop.
kotlin on subscribe extension
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