0

我怎样才能让返回的客户真正从这个函数返回一个客户数组?我的意思是我会使用另一种语言Thread.SignalOneAsync callback. 我怎样才能在 JS 中做到这一点?

 var getAllFiles = function() {
 var customers = [];
 var objectStore = dbGlobals.db.transaction("files").objectStore("files");

 objectStore.openCursor().onsuccess = function(event) {
  var cursor = event.target.result;
  if (cursor) {
      if(cursor.key.indexOf(currentFolder) != -1)  {
        customers.push(cursor.value);
      }
      cursor.continue();      
  }
  else {
//  alert("Got all customers: " + customers);
    return customers;
  }
};

}

4

0 回答 0