@@ -74,7 +74,7 @@ export default (config, otherConfig) => next =>
7474 Firebase . database . enableLogging ( configs . enableLogging )
7575 }
7676
77- const ref = Firebase . database ( ) . ref ( )
77+ const rootRef = Firebase . database ( ) . ref ( )
7878
7979 const firebase = Object . defineProperty ( Firebase , '_' , {
8080 value : {
@@ -88,16 +88,16 @@ export default (config, otherConfig) => next =>
8888 } )
8989
9090 const set = ( path , value , onComplete ) =>
91- ref . child ( path ) . set ( value , onComplete )
91+ rootRef . child ( path ) . set ( value , onComplete )
9292
9393 const push = ( path , value , onComplete ) =>
94- ref . child ( path ) . push ( value , onComplete )
94+ rootRef . child ( path ) . push ( value , onComplete )
9595
9696 const update = ( path , value , onComplete ) =>
97- ref . child ( path ) . update ( value , onComplete )
97+ rootRef . child ( path ) . update ( value , onComplete )
9898
9999 const remove = ( path , onComplete ) =>
100- ref . child ( path ) . remove ( onComplete )
100+ rootRef . child ( path ) . remove ( onComplete )
101101
102102 const uploadFile = ( path , file , dbPath ) =>
103103 storageActions . uploadFile ( dispatch , firebase , { path, file, dbPath } )
@@ -109,15 +109,15 @@ export default (config, otherConfig) => next =>
109109 storageActions . deleteFile ( dispatch , firebase , { path, dbPath } )
110110
111111 const uniqueSet = ( path , value , onComplete ) =>
112- ref . child ( path )
112+ rootRef . child ( path )
113113 . once ( 'value' )
114114 . then ( snap => {
115115 if ( snap . val && snap . val ( ) !== null ) {
116116 const err = new Error ( 'Path already exists.' )
117117 if ( onComplete ) onComplete ( err )
118118 return Promise . reject ( err )
119119 }
120- return ref . child ( path ) . set ( value , onComplete )
120+ return rootRef . child ( path ) . set ( value , onComplete )
121121 } )
122122
123123 const watchEvent = ( type , path ) =>
@@ -139,7 +139,7 @@ export default (config, otherConfig) => next =>
139139 authActions . resetPassword ( dispatch , firebase , credentials )
140140
141141 firebase . helpers = {
142- ref : Firebase . database ( ) . ref ,
142+ ref : path => Firebase . database ( ) . ref ( path ) ,
143143 set,
144144 uniqueSet,
145145 push,
0 commit comments