abc
abc

Reputation: 2027

Inner workings of LiveData

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

Answers (1)

Công Hải
Công Hải

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

Related Questions