2013-02-02 18 views
1

有人能告訴我下面的代碼有什麼問題。主要問題是:indexed_db - objectstore.delete - onSuccess

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

回答

1

部分問題或主要問題是需要使用onSuccess.listen()。正如有人在另一個問題上回答:

「onSuccess是一個流。如果你想接收多個元素只是」聽「他們:onSuccess.listen。」

相關問題