Message Input View Model

LAST EDIT Aug 02 2021

MessageInputViewModel works with MessageInputView and just like other Stream's ViewModels - it uses StreamChatAndroidOffline library to communicate with Stream API.

MessageInputView gives users the possibility to enter a new chat message. Therefore, the corresponding view model contains methods that allow communicating with API and changing the view's state:

  • getActiveThread

  • setActiveThread

  • resetThread

  • sendMessage

  • sendMessageWithAttachments

  • editMessage

  • keystroke

  • stopTyping

Moreover, MessageInputViewModel exposes multiple LiveData objects which also might be helpful for updating the view's state:

  • commands

  • members

  • editMessage

Creating Message Input View Model


MessageInputViewModel can be instantiated using ChannelViewModelFactory:

Binding with MessageInputView


MessageInputViewModel can be bound with MessageInputView using MessageInputViewModelBinding:

bind method is responsible for configuring view's:

  • Message send handler

  • Available commands

  • Channel members

  • Different modes (normal, thread, edit)

  • Typing listener