We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LiveDataやStateFlow(Kotlin Coroutinesを使用する場合)を使ってデータの変更を監視し、UIに自動的に更新を通知する。
import androidx.lifecycle.LiveData import androidx.lifecycle.MutableLiveData import androidx.lifecycle.ViewModel import androidx.lifecycle.viewModelScope import kotlinx.coroutines.launch class ChatViewModel : ViewModel() { private val _messages = MutableLiveData<List<Message>>() val messages: LiveData<List<Message>> = _messages fun sendMessage(message: Message) { viewModelScope.launch { // メッセージ送信ロジックをここに記述 // 例: _messages.value?.plus(message)などでメッセージリストを更新 } } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
LiveDataやStateFlow(Kotlin Coroutinesを使用する場合)を使ってデータの変更を監視し、UIに自動的に更新を通知する。
サンプルコード
The text was updated successfully, but these errors were encountered: