/** * Load data via the proxy, and pump the records into the store * * @throws Exception */ public ObservableFuture<Void> load() throws Exception { if (lastLoadingFuture != null) { // cancel the old ones. lastLoadingFuture.cancel(); lastProxyLoadingFuture.cancel(); } // this might take a long time. // unfortunately i can't sync during it. // but this means that after a LOAD operation is requested, // any adds that someone does will be overridden by the proxy.load() return value. // note: unfortunately this is synchronous. lastProxyLoadingFuture = proxy.load(); lastLoadingFuture = new DefaultObservableFuture<Void>(this); // listen for completion of this future. lastProxyLoadingFuture.addObserver(onLoadCompleteCallback); // this whitespace might be all it takes to miss a callback, so we have to listen first, check // second. if (handleImmediatelyDone(lastProxyLoadingFuture, lastLoadingFuture)) { lastProxyLoadingFuture.removeObserver(onLoadCompleteCallback); } return lastLoadingFuture; }