1

有人可以告诉我以下代码有什么问题。主要问题是该行:

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}"));
}
4

1 回答 1

1

部分问题或主要问题是需要使用 onSuccess.listen()。正如有人在另一个问题上回答的那样:

“onSuccess 是一个流。如果你想接收多个元素,只需“监听”它们:onSuccess.listen。”

于 2013-02-04T02:33:03.547 回答