Last active
June 10, 2020 00:13
-
-
Save sle-c/0257ad9e94efbd11be8e3a6424b05174 to your computer and use it in GitHub Desktop.
Do something if initial load
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function handleActivitySubscription(snapshot, counter) { | |
const initialLoad = counter === 1; | |
snapshot.docChanges().forEach(function(change) { | |
if (initialLoad) { | |
doSomething(change.doc.data()); | |
} else { | |
doSomethingElse(change.doc.data()); | |
} | |
}); | |
} | |
const handleActivitySubscriptionWithCounter = | |
createFnCounter(handleActivitySubscription, 0); | |
db.collection("activities").where("userID", "==", currentUserID) | |
.onSnapshot(handleActivitySubscriptionWithCounter); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, Thanks for this code, can you provide me the same code in java for android