use Promise.all to await dependencies

This commit is contained in:
siikamiika 2020-02-13 16:26:45 +02:00
parent 38a6433a46
commit d7e1ef01d8
2 changed files with 6 additions and 5 deletions

View File

@ -47,9 +47,9 @@ class DisplaySearch extends Display {
async prepare() { async prepare() {
try { try {
await super.prepare(); const superPromise = super.prepare();
const queryParserPromise = this.queryParser.prepare();
await this.queryParser.prepare(); await Promise.all([superPromise, queryParserPromise]);
const {queryParams: {query='', mode=''}} = parseUrl(window.location.href); const {queryParams: {query='', mode=''}} = parseUrl(window.location.href);

View File

@ -44,8 +44,9 @@ class Display {
} }
async prepare(options=null) { async prepare(options=null) {
await this.displayGenerator.prepare(); const displayGeneratorPromise = this.displayGenerator.prepare();
await this.updateOptions(options); const updateOptionsPromise = this.updateOptions(options);
await Promise.all([displayGeneratorPromise, updateOptionsPromise]);
yomichan.on('optionsUpdate', () => this.updateOptions(null)); yomichan.on('optionsUpdate', () => this.updateOptions(null));
} }