Skip to content Skip to sidebar Skip to footer

How To Run A Set Of Code Once Previous Line Is Completed?

I have tried debugging each line of below code. After reaching .get().addOnSuccessListener(documentSnapshot -> in database.collection('users') section. The code database.coll

Solution 1:

In that case you would have to make the second query in the Success listener:

database.collection("users")
    */ ... */
    .get().addOnSuccessListener(documentSnapshot -> {
        int a = Integer.parseInt(documentSnapshot.getString("LastQuestion")));
        database.collection("categories")
                /* ... */
                .whereGreaterThan("index", a)
                /* ... */
                .get().addOnSuccessListener(queryDocumentSnapshots -> {
                    for (DocumentSnapshot snapshot : queryDocumentSnapshots) {
                        /* ... */
                    }
                }
}

Post a Comment for "How To Run A Set Of Code Once Previous Line Is Completed?"