8000 feat(useRTDB): add errorHandler option (#3232) · vueuse/vueuse@b5e52f5 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit b5e52f5

Browse files
authored
feat(useRTDB): add errorHandler option (#3232)
1 parent 17a725e commit b5e52f5

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

packages/firebase/useRTDB/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { ref } from 'vue-demi'
55
import { tryOnScopeDispose } from '@vueuse/shared'
66

77
export interface UseRTDBOptions {
8+
errorHandler?: (err: Error) => void
89
autoDispose?: boolean
910
}
1011

@@ -18,6 +19,7 @@ export function useRTDB<T = any>(
1819
options: UseRTDBOptions = {},
1920
) {
2021
const {
22+
errorHandler = (err: Error) => console.error(err),
2123
autoDispose = true,
2224
} = options
2325
const data = ref(undefined) as Ref<T | undefined>
@@ -26,7 +28,7 @@ export function useRTDB<T = any>(
2628
data.value = snapshot.val()
2729
}
2830

29-
const off = onValue(docRef, update)
31+
const off = onValue(docRef, update, errorHandler)
3032

3133
if (autoDispose)
3234
tryOnScopeDispose(() => off())

0 commit comments

Comments
 (0)
0