Reputation: 2027
If I call LiveData.setValue()
before any observers are attached.
Then I attach an observer like so, LiveData.observe(...)
will the onChanged()
method still be called, or it will only be called if I observe before setValue?
Upvotes: 4
Views: 254
Reputation: 5261
From documents of LiveData method observe you can check here
Adds the given observer to the observers list within the lifespan of the given owner. The events are dispatched on the main thread. If LiveData already has data set, it will be delivered to the observer.
Upvotes: 2