Why LiveData observer is being triggered twice for a newly attached observer
My understanding on LiveData is that, it will trigger observer on the current state change of data, and not a series of history state change of data. Currently, I have a MainFragment , which perform Room write operation, to change non-trashed data , to trashed data . I also another TrashFragment , which observes to trashed data . Consider the following scenario. There are currently 0 trashed data . MainFragment is the current active fragment. TrashFragment is not created yet. MainFragment added 1 trashed data . Now, there are 1 trashed data We use navigation drawer, to replace MainFragment