RefirebaseRefirebase

onChildAdded

Listen for new child nodes added at the given path.

Usage

Ideal for list-style data such as chat messages or activity feeds. Fires for each existing child and then for any new children added.

Example
import { db } from 'refirebase';

const stop = db.realtime.onChildAdded('messages', (child) => {
  console.log(child.key, child.val());
});

// Later, to stop listening:
stop();

Parameters

ParamTypeDescription
path*stringThe path to the parent node.
callback*(snapshot: DataSnapshot) => voidFunction called when a child is added.

Return value

Returns

() => void

An unsubscribe function to stop listening.