LiveDataの挙動
Home画面にいって(アプリが裏に行く)、アプリを起動してもLiveDataは発火しない。Home画面でアプリが裏にいる時に、データに更新があって再度アプリが起動すると発火する。
EventObserverの挙動
EventObserverの話が以下記事にある。
LiveData with SnackBar, Navigation and other events (the SingleLiveEvent case)
2021 Update: This guidance is deprecated in favor of the official guidelines.
コメントのMykola Morgunさんと記事作成者のやり取りで
I’m new to Android and after reading this a few times I don’t really get what’s wrong with “Bad: 1. Using LiveData for events”.
I have written a few simple apps for training where I use this (and right now I specificaally made an app with the 2nd activity being launched from LiveData) and there’s no such scenario where LiveData fires twice.
Maybe I did not enough testing and there is some specific lifecycle scenario where this emerges?
Navigate using LiveData, press back, rotate phone. It will navigate again.
と記載があり、EventObserverは端末が回転した時に発火させないようにする時に使いそう。