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
| Param | Type | Description |
|---|---|---|
path* | string | The path to the parent node. |
callback* | (snapshot: DataSnapshot) => void | Function called when a child is added. |
Return value
Returns
() => voidAn unsubscribe function to stop listening.