The documentation says:
You can listen to a document with the onSnapshot() method. An initial call using the callback you provide creates a document s
Firestore listeners loads by their own order and the "onSnapshot" event must always execute first on initial state. But, you can handle that behavior adding a initial state variable like:
var initState = true;
db.collection('col').doc('id').onSnapshot(....
Then you could validate inside the function the code you dont want to run when your application starts.
var initState = true;
db.collection('col').doc('id').onSnapshot(....
if(!initState){ // if is not initial state
//your code
}
and after the application starts up you must change initState to false and add a sleep/timeout function (cause it may have an unexpcted asyncronous load)
var initState = true;
db.collection('col').doc('id').onSnapshot(....
if(!initState){ // if is not initial state
//your code
}
setTimeout(function () { // cause onSnapShot executes first
initState = false;
}, 2000);