/** Returns whether this future is complete right now. This is an unfortunate name, but I * foolishly defined {@link #isComplete} to return a reactive view of completeness. */ public boolean isCompleteNow () { return result() != null; }
/** Returns whether this future is complete right now. This is an unfortunate name, but I * foolishly defined {@link #isComplete} to return a reactive view of completeness. */ public boolean isCompleteNow () { return result() != null; }
/** Returns a future with a pre-existing success value. */ public static <T> RFuture<T> success (T value) { return result(Try.success(value)); }
/** * Returns whether this image is successfully loaded. If it is still loading, or loading failed, * {@code false} will be returned. In general you'll want to react to {@link #state}, but this * method is useful when you need to assert that something is only allowed on a fully loaded * image. */ public boolean isLoaded () { Try<Image> cur = state.result(); return cur != null && cur.isSuccess(); }
/** * Returns whether this image is successfully loaded. If it is still loading, or loading failed, * {@code false} will be returned. In general you'll want to react to {@link #state}, but this * method is useful when you need to assert that something is only allowed on a fully loaded * image. */ public boolean isLoaded () { Try<Image> cur = state.result(); return cur != null && cur.isSuccess(); }
/** Returns a future with a pre-existing success value. */ public static <T> RFuture<T> success (T value) { return result(Try.success(value)); }
/** Returns a future with a pre-existing failure value. */ public static <T> RFuture<T> failure (Throwable cause) { return result(Try.<T>failure(cause)); }
/** Returns a future with a pre-existing failure value. */ public static <T> RFuture<T> failure (Throwable cause) { return result(Try.<T>failure(cause)); }
/** Causes {@code slot} to be notified when this future is completed. If it has already * completed, the slot will be notified immediately. * @return this future for chaining. */ public RFuture<T> onComplete (final SignalView.Listener<? super Try<T>> slot) { Try<T> result = result(); if (result != null) slot.onEmit(result); else addConnection(slot); return this; }
/** Causes {@code slot} to be notified when this future is completed. If it has already * completed, the slot will be notified immediately. * @return this future for chaining. */ public RFuture<T> onComplete (final SignalView.Listener<? super Try<T>> slot) { Try<T> result = result(); if (result != null) slot.onEmit(result); else addConnection(slot); return this; }
/** * Loads a JSON encoded library synchronously. * @param baseDir The base directory, containing library.json and texture atlases. */ public static Library loadLibrarySync (final Platform plat, String baseDir) throws Exception { final ImageLoader syncLoader = new ImageLoader() { @Override public Image load (String path) { return plat.assets().getImageSync(path); } }; String text = plat.assets().getTextSync(baseDir + "/library.json"); Try<Library> result = decodeLibrary(plat.json().parse(text), baseDir, syncLoader).result(); if (result.isSuccess()) return result.get(); Throwable error = result.getFailure(); if (error instanceof Exception) throw (Exception)error; else throw new RuntimeException(error); }