Add example async/await to test Babel transform

This commit is contained in:
Dan Stillman 2017-05-24 00:59:45 -04:00
parent 6afc58a629
commit aa321f3495

View file

@ -70,7 +70,7 @@ Zotero.ItemTreeView.prototype.collapseAll = false;
/** /**
* Called by the tree itself * Called by the tree itself
*/ */
Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (treebox) { Zotero.ItemTreeView.prototype.setTree = async function (treebox) {
try { try {
Zotero.debug("Setting tree for " + this.collectionTreeRow.id + " items view " + this.id); Zotero.debug("Setting tree for " + this.collectionTreeRow.id + " items view " + this.id);
var start = Date.now(); var start = Date.now();
@ -115,7 +115,7 @@ Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (tree
return; return;
} }
yield this.refresh(true); await this.refresh(true);
if (!this._treebox.treeBody) { if (!this._treebox.treeBody) {
return; return;
} }
@ -280,14 +280,14 @@ Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (tree
if (this.collectionTreeRow && this.collectionTreeRow.itemToSelect) { if (this.collectionTreeRow && this.collectionTreeRow.itemToSelect) {
var item = this.collectionTreeRow.itemToSelect; var item = this.collectionTreeRow.itemToSelect;
yield this.selectItem(item['id'], item['expand']); await this.selectItem(item['id'], item['expand']);
this.collectionTreeRow.itemToSelect = null; this.collectionTreeRow.itemToSelect = null;
} }
Zotero.debug("Set tree for items view " + this.id + " in " + (Date.now() - start) + " ms"); Zotero.debug("Set tree for items view " + this.id + " in " + (Date.now() - start) + " ms");
this._initialized = true; this._initialized = true;
yield this.runListeners('load'); await this.runListeners('load');
} }
catch (e) { catch (e) {
Zotero.debug(e, 1); Zotero.debug(e, 1);
@ -297,7 +297,7 @@ Zotero.ItemTreeView.prototype.setTree = Zotero.Promise.coroutine(function* (tree
} }
throw e; throw e;
} }
}); }
Zotero.ItemTreeView.prototype.setSortColumn = function() { Zotero.ItemTreeView.prototype.setSortColumn = function() {