多个 LiveData 观察者调用序列

Multiple LiveData observer call sequence

假设我有一个 LiveData l 和多个观察者 o1, o2, o3l 上观察。当 l 的值发生变化时,调用观察者的顺序是什么?是观察者依附的序列l?还是不确定的?

从源代码来看,它似乎迭代了所有观察者并通知他们有关数据的更改。

for (Iterator<Map.Entry<Observer<? super T>, ObserverWrapper>> iterator =
                        mObservers.iteratorWithAdditions(); iterator.hasNext(); ) {
                    considerNotify(iterator.next().getValue());
                    if (mDispatchInvalidated) {
                        break;
                    }
                }

我希望是前者。

LiveData 使用 SafeIterableMap.iteratorWithAdditions() to iterate over its observers and notify them. The documentation described SafeIterableMap 作为“LinkedList,伪装成地图”。