Reputation: 9923
I have a LiveData
and, say, n Observer
s of it. One of the Observer
s, call it o
, updates global state, upon which the other n-1 Observer
s depend.
Is there any way to guarantee that o
is executed first? Is it merely that o
be added first?
I've looked through the relevant docs and see nothing mentioned explicitly.
Upvotes: 1
Views: 700
Reputation: 17258
Theoretically there's no specific guarantee declared that I'm aware of.
Practically as long as all of your observers are added using the same lifecycleOwner
they should be invoked in registration order as LiveData
internally uses forward iteration (source code) to update them.
Upvotes: 2