如何等待直到Firestore上的删除功能完成

时间:2019-02-26 05:01:29

标签: swift google-cloud-firestore

我的应用程序中包含以下代码。

public void onAddField(View v) {
        LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        final View rowView = inflater.inflate(R.layout.field, null);
        parentLinearLayout.addView(rowView, parentLinearLayout.getChildCount() - 1);

    }
public void onDelete(View v) {
        parentLinearLayout.removeView((View) v.getParent());
    }

注销操作在删除之前完成,因此无法在Firestore上完成删除。我如何等待尝试注销,直到删除功能完成?

1 个答案:

答案 0 :(得分:0)

您可以使用闭包:

db.collection("users").document(currentUserId).updateData(["Token": FieldValue.delete()]) {
    err in
    if err == nil {
       do {
           try Auth.auth().signOut()
       } catch let error {
           // Sign out failed with error, do something
       }
    } else {
       // Update database error, do something
    }
}