onValue
Subscribe to real-time value changes at the given path.
Usage
Fires immediately with the current value, then on every change.
Example
import { db } from 'refirebase';
const unsubscribe = await db.realtime.onValue('users/123', (data) => {
console.log('User data:', data);
});
// Later, to stop listening:
unsubscribe();Parameters
| Param | Type | Description |
|---|---|---|
path* | string | The path to the data in the database. |
callback* | (data: T | null) => void | Function called immediately and whenever the data changes. |
Return value
Returns
Promise<() => void>A promise that resolves to an unsubscribe function.