ChildEventListener

interface ChildEventListener


Classes implementing this interface can be used to receive events about changes in the child locations of a given DatabaseReference ref. Attach the listener to a location using addChildEventListener and the appropriate method will be triggered when changes occur.

Summary

Public functions

Unit

This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules.

Unit
onChildAdded(snapshot: DataSnapshot, previousChildName: String?)

This method is triggered when a new child is added to the location to which this listener was added.

Unit
onChildChanged(snapshot: DataSnapshot, previousChildName: String?)

This method is triggered when the data at a child location has changed.

Unit
onChildMoved(snapshot: DataSnapshot, previousChildName: String?)

This method is triggered when a child location's priority changes.

Unit

This method is triggered when a child is removed from the location to which this listener was added.

Public functions

onCancelled

fun onCancelled(error: DatabaseError): Unit

This method will be triggered in the event that this listener either failed at the server, or is removed as a result of the security and Firebase rules. For more information on securing your data, see: Security Quickstart

Parameters
error: DatabaseError

A description of the error that occurred

onChildAdded

fun onChildAdded(snapshot: DataSnapshot, previousChildName: String?): Unit

This method is triggered when a new child is added to the location to which this listener was added.

Parameters
snapshot: DataSnapshot

An immutable snapshot of the data at the new child location

previousChildName: String?

The key name of sibling location ordered before the new child. This will be null for the first child node of a location.

onChildChanged

fun onChildChanged(snapshot: DataSnapshot, previousChildName: String?): Unit

This method is triggered when the data at a child location has changed.

Parameters
snapshot: DataSnapshot

An immutable snapshot of the data at the new data at the child location

previousChildName: String?

The key name of sibling location ordered before the child. This will be null for the first child node of a location.

onChildMoved

fun onChildMoved(snapshot: DataSnapshot, previousChildName: String?): Unit

This method is triggered when a child location's priority changes. See setPriority and Ordered Data for more information on priorities and ordering data.

Parameters
snapshot: DataSnapshot

An immutable snapshot of the data at the location that moved.

previousChildName: String?

The key name of the sibling location ordered before the child location. This will be null if this location is ordered first.

onChildRemoved

fun onChildRemoved(snapshot: DataSnapshot): Unit

This method is triggered when a child is removed from the location to which this listener was added.

Parameters
snapshot: DataSnapshot

An immutable snapshot of the data at the child that was removed.