Skip to content

Commit 0748364

Browse files
authored
Updated docstring for off (#6407)
Updated recommendations for adding/removing event callbacks in RTDB.
1 parent 691292b commit 0748364

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

packages/database/src/api/Reference_impl.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1600,12 +1600,11 @@ export function onChildRemoved(
16001600
export { EventType };
16011601

16021602
/**
1603-
* Detaches a callback previously attached with `on()`.
1603+
* Detaches a callback previously attached with the corresponding `on*()` (`onValue`, `onChildAdded`) listener.
1604+
* Note: This is not the recommended way to remove a listener. Instead, please use the returned callback function from
1605+
* the respective `on*` callbacks.
16041606
*
1605-
* Detach a callback previously attached with `on()`. Note that if `on()` was
1606-
* called multiple times with the same eventType and callback, the callback
1607-
* will be called multiple times for each event, and `off()` must be called
1608-
* multiple times to remove the callback. Calling `off()` on a parent listener
1607+
* Detach a callback previously attached with `on*()`. Calling `off()` on a parent listener
16091608
* will not automatically remove listeners registered on child nodes, `off()`
16101609
* must also be called on any child listeners to remove the callback.
16111610
*

0 commit comments

Comments
 (0)