@@ -26,29 +26,20 @@ function subscribeToRefs ({
2626 delete subs [ refKey ]
2727 } )
2828 if ( ! refKeys . length ) return resolve ( )
29- // TODO check if no ref is missing
3029 // TODO max depth param, default to 1?
3130 if ( ++ depth > 3 ) throw new Error ( 'more than 5 nested refs' )
3231
3332 refKeys . forEach ( refKey => {
34- // check if already bound to the same ref -> skip
35- // TODO reuse if already bound?
3633 const sub = subs [ refKey ]
3734 const ref = refs [ refKey ]
3835
36+ // unsubscribe if bound to a different ref
3937 if ( sub ) {
4038 if ( sub . path !== ref . path ) sub . unsub ( )
4139 // if has already be bound and as we always walk the objects, it will work
4240 else return
4341 }
4442
45- // maybe wrap the unbind function to call unbind on every child
46- // const [innerObj, innerKey] = deepGetSplit(target[key], refKey)
47- // if (!innerObj) {
48- // console.log('=== ERROR ===')
49- // console.log(data, refKey, key, innerObj, innerKey)
50- // console.log('===')
51- // }
5243 subs [ refKey ] = {
5344 unsub : subscribeToDocument ( {
5445 ref,
@@ -69,8 +60,7 @@ function bindCollection ({
6960 resolve,
7061 reject
7162} ) {
72- // TODO wait to get all data
73- // XXX support pathes? nested.obj.list
63+ // TODO support pathes? nested.obj.list (walkSet)
7464 const array = vm [ key ] = [ ]
7565 const originalResolve = resolve
7666 let isResolved
@@ -137,7 +127,6 @@ function bindCollection ({
137127 resolve = ( { id } ) => {
138128 if ( id in validDocs ) {
139129 if ( ++ count >= expectedItems ) {
140- // TODO use array instead?
141130 originalResolve ( vm [ key ] )
142131 // reset resolve to noop
143132 resolve = _ => { }
@@ -227,7 +216,6 @@ function bindDocument ({
227216 }
228217 } , reject )
229218
230- // TODO return a custom unbind function that unbind all refs
231219 return ( ) => {
232220 unbind ( )
233221 unsubscribeAll ( subs )
0 commit comments