Rework libraryTreeView event handling

Changes `libraryTreeView::addEventListener('load')` and similar to
`libraryTreeView::onLoad.addListener(listener, once)`, etc. `once` is an
optional boolean that, when true, causes the listener to fire once and
then be removed. This is implicit for 'load'.

'load' maintains its special behavior of running immediately if the
treeview has already been loaded.

Also adds `waitForLoad()` and `waitForSelect()` functions that return
promises on event completion, since most uses of those events were just
resolving deferreds.
This commit is contained in:
Dan Stillman 2017-03-24 05:18:55 -04:00
parent 1a4b7121d3
commit 820755e152
10 changed files with 105 additions and 99 deletions

View file

@ -35,8 +35,7 @@ describe("Advanced Search", function () {
var deferred = Zotero.Promise.defer();
o.search();
var iv = o.itemsView;
iv.addEventListener('load', () => deferred.resolve());
yield deferred.promise;
yield iv.waitForLoad();
// Check results
assert.equal(iv.rowCount, 1);