我注意到在能够检索结果和创建以及IndexedDB objectStore的填充之间存在相当大的延迟。我怀疑在完成大量“put”之后索引仍在运行,但我不确定如何测量每个部分(createobjectStore,createIndex)并报告回来。
是否有一种简单的方法可以检查正在创建的索引是否成功?
import { Component } from '@angular/core';
import { InAppBrowser, Splashscreen } from 'ionic-native';
import { Platform } from 'ionic-angular';
import 'rxjs/Rx';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
browser: InAppBrowser;
sysBrowser: InAppBrowser;
urlHistory: string[] = [];
url: string;
constructor(public platform: Platform) {
this.platform = platform;
this.url = 'http://www.yourdomain.com/support';
}
ionViewDidLoad() {
this.platform.ready().then(() => {
this.browser = new InAppBrowser(this.url, '_blank', 'location=no,zoom=no,hidden=no');
this.urlHistory.push(this.url);
this.addEventsToBlankBrowser();
});
}
addEventsToBlankBrowser() {
this.browser.on('loadstart').subscribe(
event => {
if (event.url.indexOf('www.yourdomain.com') === -1) {
let previousUrl = this.urlHistory.pop();
this.browser.executeScript({ code: 'window.location.href = "' + previousUrl + '";' });
this.sysBrowser = new InAppBrowser(event.url, '_system');
this.url = previousUrl;
this.urlHistory.push(previousUrl);
this.browser = new InAppBrowser(previousUrl, '_blank', 'location=yes,zoom=no,hidden=no');
this.browser.show();
this.addEventsToBlankBrowser();
} else {
this.url = event.url;
this.urlHistory.push(event.url);
}
}
);
}
}
答案 0 :(得分:1)
当然,只需听取request
的成功事件。在升级功能完成之前,不会引发成功事件。
var request = indexedDB.open(...);
request.onupgradeneeded = function() {
// create indices and whatever
store.createIndex(...);
};
request.onsuccess = function() {
console.log('this shows up after the upgrade completes');
};