77 noop ,
88 OperationsType ,
99 ResetOption ,
10+ TODO ,
1011 _DataSourceOptions ,
1112 _ResolveRejectFn ,
1213} from '../shared'
@@ -56,27 +57,18 @@ const DEFAULT_OPTIONS: _DatabaseRefOptionsWithDefaults = {
5657
5758export { DEFAULT_OPTIONS as databaseOptionsDefaults }
5859
59- interface CommonBindOptionsParameter {
60- target : Ref < any >
61- resolve : _ResolveRejectFn
62- reject : _ResolveRejectFn
63- ops : OperationsType
64- }
65-
66- // TODO: refactor using normal arguments instead of an array to improve size
67-
68- interface BindAsObjectParameter extends CommonBindOptionsParameter {
69- document : DatabaseReference | Query
70- }
71-
7260/**
7361 * Binds a Firebase Database reference as an object
7462 * @param param0
7563 * @param options
7664 * @returns a function to be called to stop listening for changes
7765 */
7866export function bindAsObject (
79- { target, document, resolve, reject, ops } : BindAsObjectParameter ,
67+ target : Ref < unknown > ,
68+ document : DatabaseReference | Query ,
69+ resolve : _ResolveRejectFn ,
70+ reject : _ResolveRejectFn ,
71+ ops : OperationsType ,
8072 extraOptions : _DatabaseRefOptions = DEFAULT_OPTIONS
8173) {
8274 const key = 'value'
@@ -102,18 +94,18 @@ export function bindAsObject(
10294 }
10395}
10496
105- interface BindAsArrayParameter extends CommonBindOptionsParameter {
106- collection : DatabaseReference | Query
107- }
108-
10997/**
11098 * Binds a RTDB reference or query as an array
11199 * @param param0
112100 * @param options
113101 * @returns a function to be called to stop listening for changes
114102 */
115103export function bindAsArray (
116- { target, collection, resolve, reject, ops } : BindAsArrayParameter ,
104+ target : Ref < TODO > ,
105+ collection : DatabaseReference | Query ,
106+ resolve : _ResolveRejectFn ,
107+ reject : _ResolveRejectFn ,
108+ ops : OperationsType ,
117109 extraOptions : _DatabaseRefOptions = DEFAULT_OPTIONS
118110) {
119111 const options = Object . assign ( { } , DEFAULT_OPTIONS , extraOptions )
@@ -128,9 +120,8 @@ export function bindAsArray(
128120 const array = unref ( arrayRef )
129121 const index = prevKey ? indexForKey ( array , prevKey ) + 1 : 0
130122 ops . add ( array , index , options . serialize ( snapshot ) )
131- }
132- // TODO: cancelcallback
133- // reject,
123+ } ,
124+ reject
134125 )
135126
136127 const removeChildRemovedListener = onChildRemoved (
@@ -139,8 +130,8 @@ export function bindAsArray(
139130 ( snapshot ) => {
140131 const array = unref ( arrayRef )
141132 ops . remove ( array , indexForKey ( array , snapshot . key ) )
142- }
143- // TODO: cancelcallback
133+ } ,
134+ reject
144135 )
145136
146137 const removeChildChangedListener = onChildChanged (
@@ -152,8 +143,8 @@ export function bindAsArray(
152143 indexForKey ( array , snapshot . key ) ,
153144 options . serialize ( snapshot )
154145 )
155- }
156- // TODO: cancelcallback
146+ } ,
147+ reject
157148 )
158149
159150 const removeChildMovedListener = onChildMoved (
@@ -164,8 +155,8 @@ export function bindAsArray(
164155 const oldRecord = ops . remove ( array , index ) [ 0 ]
165156 const newIndex = prevKey ? indexForKey ( array , prevKey ) + 1 : 0
166157 ops . add ( array , newIndex , oldRecord )
167- }
168- // TODO: cancelcallback
158+ } ,
159+ reject
169160 )
170161
171162 // in case the removeValueListener() is called before onValue returns
0 commit comments