Skip to content

Commit

Permalink
fix: checking if references typeof is function
Browse files Browse the repository at this point in the history
  • Loading branch information
ralacerda committed Feb 22, 2024
1 parent 53d1ddb commit cc42959
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/database/useDatabaseRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export function _useDatabaseRef(
}

let stopWatcher = noop
if (isRef(reference)) {
if (isRef(reference) || typeof reference === 'function') {
stopWatcher = watch(reference, bindDatabaseRef)
}
bindDatabaseRef()
Expand Down
4 changes: 3 additions & 1 deletion src/firestore/useFirestoreRef.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export function _useFirestoreRef(
}

let stopWatcher = noop
stopWatcher = watch(() => toValue(docOrCollectionRef), bindFirestoreRef)
if (isRef(docOrCollectionRef) || typeof docOrCollectionRef === 'function') {
stopWatcher = watch(docOrCollectionRef, bindFirestoreRef)
}

bindFirestoreRef()

Expand Down
4 changes: 2 additions & 2 deletions src/storage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export function useStorageFileUrl(
}

refresh()
if (isRef(storageRef)) {
if (isRef(storageRef) || typeof storageRef === 'function') {
watch(storageRef, refresh)
}

Expand Down Expand Up @@ -255,7 +255,7 @@ export function useStorageFile(
return Promise.all([refreshUrl(), refreshMetadata()])
}

if (isRef(storageRef)) {
if (isRef(storageRef) || typeof storageRef === 'function') {
watch(storageRef, (storageSource) => {
if (!storageSource) {
if (uploadTask.value) {
Expand Down

0 comments on commit cc42959

Please sign in to comment.