Created
May 6, 2020 13:30
-
-
Save samiuelson/8569f8eb1bad49b49fdc440315d76d9b to your computer and use it in GitHub Desktop.
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 LiveStreamViewModel() : ViewModel() { | |
private val chatClient = ChatClient.instance() | |
private val _viewState = MutableLiveData<State>() | |
private lateinit var channelController: ChannelController | |
val viewState: LiveData<State> = _viewState | |
init { | |
chatClient.setUser(chatUser, USER_TOKEN, object : InitConnectionListener() { | |
override fun onSuccess(data: ConnectionData) { | |
channelController = chatClient.channel(CHANNEL_TYPE, CHANNEL_ID) | |
requestChannel() | |
subscribeToNewMessageEvent() | |
} | |
override fun onError(error: ChatError) { | |
_viewState.postValue(State.Error("User setting error")) | |
Timber.e(error) | |
} | |
}) | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment