Reputation: 529
var items: Int by Delegates.notNull<Int>()
db.collection("Testdatabase").get().addOnSuccessListener{ snap->
items=snap.size()
}
Log.i("items",items.toString())
and it says
Property items should be initialized before get
I have to use 'items' variable as a size of the snapshot. I searched some google but I can't figure out.. Can any one help please?
Upvotes: 0
Views: 1533
Reputation: 408
That happens because your addOnSuccessListener
takes some time to get data. So in this example, you need to put your log statement inside addOnSuccessListener
and you will be fine
Upvotes: 1