Is it good idea to get callback for successful roo...
# android-architecture
r
Is it good idea to get callback for successful room transaction by passing a lambda function in Kotlin Android? For example:
Copy code
fun insertNewData(oldList: List<String>, finalList: List<String>, callback: () -> Unit) {
        launch(<http://Dispatchers.IO|Dispatchers.IO>) {
            async {
                //1. Call function to delete old relations
                // Delete query on JoinTable

                //2.Call function to get IDs for new data
                // Select query on TableOne
                
                //3. Call function to assign new relations
                // Insert query on JoinTable
            }.await()
            
            callback()
        }
    }
Is it a good setup or there are better ways? Another thing, I am using LiveData but for few cases prefer a lambda function as callback where I want to listen for a response only once.