首页 > 解决方案 > How to do ParseQuery for each item in a list of ParseObjects

问题描述

I want to do ParseAPI call in Kotlin where input is List<ParseObject> and output is update MutableList<CustomObject> where CustomObject is data class containing ParseObject and Int. I can do something like this:

var newItems = mutableListOf<CustomObject>()
items.forEach{
//do query on relation column of item
//inside query.findInBackground -> (if error == null) add item to newItems
}

But I need to call callback function when new list is finished. I need something like await function for this call. Because i have to wait till callbacks for each item have ended and then return results to Activity.

That means function for query is defined like this:

fun getCurrentItems(c: Context, items: List<ParseObject>, callback:(MutableList<CustomObject>) -> Unit)

If all items were checked I just want to call:

callback(newItems)

标签: androidkotlinparse-platform

解决方案


推荐阅读