Last active
November 14, 2019 17:30
-
-
Save JosiasSena/8aeed6bc4b4f433f6b40daf7f6a822f9 to your computer and use it in GitHub Desktop.
Gists for https://medium.com/@josiassena/graphql-websocket-subscriptions-on-android-using-apollo-7e7311afdfca
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
class SomePresenterOrViewModelEtc(private val api: GraphQLApi) { | |
// ... | |
fun sunscribeToMessages() { | |
val messagesSubscription = OnNewMessagesReceivedSubscription.builder() | |
.groupUUID("uuid") | |
.build() | |
api.subscribe(messagesSubscription) | |
.subscribeOn(Schedulers.io()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe({ | |
// handle results, like adding the result into a list | |
}, { | |
// handle errors | |
}).addTo(compositeDisposable) | |
} | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment