Skip to content

Commit 7b8b037

Browse files
committed
refactor: remove manual bind/unbind methods
BREAKING CHANGE: manual bind, and unbind from database and firestore have been remove. Use the new functions `useList()`/`useCollection()` and `useObject()`/`useDocument()` instead.
1 parent a636c21 commit 7b8b037

File tree

2 files changed

+3
-41
lines changed

2 files changed

+3
-41
lines changed

Diff for: src/database/index.ts

+1-29
Original file line numberDiff line numberDiff line change
@@ -82,30 +82,6 @@ export function internalUnbind(
8282
// delete vm._firebaseUnbinds[key]
8383
}
8484

85-
export function bind(
86-
target: Ref,
87-
reference: DatabaseReference | Query,
88-
options?: RTDBOptions
89-
) {
90-
const unbinds = {}
91-
rtdbUnbinds.set(target, unbinds)
92-
const promise = internalBind(target, '', reference, unbinds, options)
93-
94-
// TODO: SSR serialize the values for Nuxt to expose them later and use them
95-
// as initial values while specifying a wait: true to only swap objects once
96-
// Firebase has done its initial sync. Also, on server, you don't need to
97-
// create sync, you can read only once the whole thing so maybe internalBind
98-
// should take an option like once: true to not setting up any listener
99-
100-
if (getCurrentInstance()) {
101-
onBeforeUnmount(() => {
102-
unbind(target, options && options.reset)
103-
})
104-
}
105-
106-
return promise
107-
}
108-
10985
// export function useList(reference: DatabaseReference | Query, options?: RTDBOptions)
11086

11187
/**
@@ -176,11 +152,7 @@ export function useObject<T = unknown>(
176152
pending.value = false
177153
})
178154

179-
// TODO: SSR serialize the values for Nuxt to expose them later and use them
180-
// as initial values while specifying a wait: true to only swap objects once
181-
// Firebase has done its initial sync. Also, on server, you don't need to
182-
// create sync, you can read only once the whole thing so maybe internalBind
183-
// should take an option like once: true to not setting up any listener
155+
// TODO: refactor code to avoid duplication
184156

185157
if (getCurrentScope()) {
186158
onScopeDispose(() => {

Diff for: src/index.ts

+2-12
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,12 @@
1-
export {
2-
bind as rtdbBind,
3-
unbind as rtdbUnbind,
4-
useList,
5-
useObject,
6-
} from './database'
1+
export { useList, useObject } from './database'
72

83
export { databasePlugin } from './database/optionsApi'
94
export type { DatabasePluginOptions } from './database/optionsApi'
105

116
// TODO: rename and move to database
127
export type { RTDBOptions } from './core'
138

14-
export {
15-
bind as firestoreBind,
16-
unbind as firestoreUnbind,
17-
useCollection,
18-
useDocument,
19-
} from './firestore'
9+
export { useCollection, useDocument } from './firestore'
2010

2111
export type {
2212
UseCollectionOptions,

0 commit comments

Comments
 (0)