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 1
1
{
2
- "version" : " 0.1.0 " ,
2
+ "version" : " 0.1.1 " ,
3
3
"name" : " sveltefire" ,
4
4
"svelte" : " src/index.js" ,
5
5
"main" : " dist/index.js" ,
Original file line number Diff line number Diff line change @@ -16,14 +16,17 @@ export function docStore(path, opts) {
16
16
17
17
// Internal state
18
18
let _loading = typeof startWith !== undefined ;
19
+ let _firstValue = true ;
19
20
let _error = null ;
20
21
let _teardown ;
21
22
let _waitForIt ;
22
23
24
+
23
25
// State should never change without emitting a new value
24
26
// Clears loading state on first call
25
27
const next = ( val , err ) => {
26
28
_loading = false ;
29
+ _firstValue = false ;
27
30
_waitForIt && clearTimeout ( _waitForIt ) ;
28
31
_error = err || null ;
29
32
set ( val ) ;
@@ -40,7 +43,7 @@ export function docStore(path, opts) {
40
43
// Realtime firebase subscription
41
44
_teardown = ref . onSnapshot (
42
45
snapshot => {
43
- const data = snapshot . data ( ) || startWith || null ;
46
+ const data = snapshot . data ( ) || ( _firstValue && startWith ) || null ;
44
47
45
48
// Optional logging
46
49
if ( log ) {
You can’t perform that action at this time.
0 commit comments