Search code examples
androidandroid-architecture-components

Multiple LiveData observer call sequence


Let's say I have one LiveData l and multiple Observers o1, o2, o3 observing on l. When value of l changes, what sequence does the observers get called? Is it the sequence that the observers are attached to l? Or is it non deterministic?


Solution

  • I'd expect the former.

    LiveData uses SafeIterableMap.iteratorWithAdditions() to iterate over its observers and notify them. The documentation described SafeIterableMap as a "LinkedList, which pretends to be a map".