File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change 11{
2- "version" : " 0.1.0 " ,
2+ "version" : " 0.1.1 " ,
33 "name" : " sveltefire" ,
44 "svelte" : " src/index.js" ,
55 "main" : " dist/index.js" ,
Original file line number Diff line number Diff line change @@ -16,14 +16,17 @@ export function docStore(path, opts) {
1616
1717 // Internal state
1818 let _loading = typeof startWith !== undefined ;
19+ let _firstValue = true ;
1920 let _error = null ;
2021 let _teardown ;
2122 let _waitForIt ;
2223
24+
2325 // State should never change without emitting a new value
2426 // Clears loading state on first call
2527 const next = ( val , err ) => {
2628 _loading = false ;
29+ _firstValue = false ;
2730 _waitForIt && clearTimeout ( _waitForIt ) ;
2831 _error = err || null ;
2932 set ( val ) ;
@@ -40,7 +43,7 @@ export function docStore(path, opts) {
4043 // Realtime firebase subscription
4144 _teardown = ref . onSnapshot (
4245 snapshot => {
43- const data = snapshot . data ( ) || startWith || null ;
46+ const data = snapshot . data ( ) || ( _firstValue && startWith ) || null ;
4447
4548 // Optional logging
4649 if ( log ) {
You can’t perform that action at this time.
0 commit comments