so i did post something about this a while ago but now ive cut down a lot on the amount of promises and now im only using them in 1 function which should create and wait for any of the events that creating a connection to the indexed db should make
async openDB() {
const open_db_req = indexedDB.open(this.name, this.version);
await this.openDBPromise(open_db_req);
console.log("tabls created");
}
openDBPromise(request): Promise<void> {
return new Promise((resolve, reject) => {
console.log("starting listener promise");
request.onsuccess = (e) => {
console.log("on success");
// create all the objects that represent all the tables in the database with a for loop
// the table objects will set themselves up in their own class
resolve();
};
request.onerror = (e) => {
console.log("on error");
console.error("open IDB error: ", e);
reject();
};
request.onupgradeneeded = (e) => {
// actually create all the database stuff that needs to be created
resolve();
};
});
}
also need to show what is calling this at the top level
databases.loadSchemas();
console.log("databases:");
console.log(databases);
console.log(JSON.stringify(databases.databases));
console.log(databases.databases.length);