What is the difference between ChildEventListener and ValueEventListener Firebase interfaces?

后端 未结 3 716
悲&欢浪女
悲&欢浪女 2021-01-01 18:22

The documentation says they both listen to changes at a Firebase database location.

3条回答
  •  被撕碎了的回忆
    2021-01-01 18:36

    They do almost same thing, though ChildEventListener can be sometimes more flexible: with ChildEventListener you can specify different behavior for 4 actions (onChildAdded, onChildChanged, onChildMoved and onChildRemoved), while ValueEventListener provides only onDataChanged.

    Also ChildEventListener provides DataSnapshots (immutable copies of the data) at child's location while ValueEventListener provides a DataSnapshot of a whole node.

提交回复
热议问题