Skip to content

Instantly share code, notes, and snippets.

@sle-c
Last active June 10, 2020 00:13
Show Gist options
  • Select an option

  • Save sle-c/0257ad9e94efbd11be8e3a6424b05174 to your computer and use it in GitHub Desktop.

Select an option

Save sle-c/0257ad9e94efbd11be8e3a6424b05174 to your computer and use it in GitHub Desktop.
Do something if initial load
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);
@skydevelopers

Copy link
Copy Markdown

Hi, Thanks for this code, can you provide me the same code in java for android

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment