有人可以告诉我以下代码有什么问题。主要问题是该行:
fDbListAllClients; // this is not being "called"
似乎没有被执行。
也可能有其他错误的代码。我不关心是否有必要检查删除,我想知道是什么原因导致问题的线路没有执行。
fDbDeleteOneClient(String sKey) {
var oDbTxn = ogDb1.transaction(sgTblClient, 'readwrite');
var oDbTable = oDbTxn.objectStore(sgTblClient);
var oDbRecord = oDbTable.getObject(sKey);
oDbRecord.onSuccess.first.then((val) {if (oDbRecord.result == null) {
window.alert("Record $sKey not found and cannot be deleted");
return;}});
var oDbDelReq = oDbTable.delete(sKey);
oDbDelReq.onSuccess.first.then((val1) {
var oDbRecord = oDbTable.getObject(sKey); // check if it was deleted
oDbRecord.onSuccess.first.then((val2){
if (oDbRecord.result != null) {
window.alert("Record $sKey was found but cannot be deleted");
}
});
fDbListAllClients; // this is not being "called"
});
oDbDelReq.onError.first.then((e) => window.alert(
"Error on Delete of $sKey. Error = ${e}"));
}
答案 0 :(得分:1)
部分问题或主要问题是需要使用onSuccess.listen()。有人回答了另一个问题:
“onSuccess是一个流。如果你想收到多个元素,只需”监听“它们:onSuccess.listen。”