Package io.deephaven.web.client.fu
Class LazyPromise<T>
java.lang.Object
io.deephaven.web.client.fu.LazyPromise<T>
- All Implemented Interfaces:
PromiseLike<T>
Tired of needing to create annoying promise lambdas?
If you want to create a promise early in a method's scope, and then configure it's handling of resolve/reject
callbacks later, or in a conditional nature, than LazyPromise is for you!
-
Field Summary
Fields inherited from interface io.deephaven.web.shared.fu.PromiseLike
CANCELLATION_MESSAGE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal elemental2.promise.Promise<T>
final elemental2.promise.Promise<T>
asPromise
(int timeout) final <V> CancellablePromise<V>
asPromise
(JsFunction<T, V> mapper, JsRunnable cancel) final CancellablePromise<T>
asPromise
(JsRunnable cancel) void
boolean
boolean
boolean
boolean
boolean
static <T> elemental2.promise.Promise.CatchOnRejectedCallbackFn<T>
logError
(JsProvider<String> msg) Eats exceptions in exchange for messages logged to the console.static Throwable
void
onFailure
(JsConsumer<Object> failure) void
onSuccess
(JsConsumer<T> success) static <T> elemental2.promise.Promise<T>
promiseLater
(T table) Create a deferred promise from a known value.static <V> elemental2.promise.IThenable<V>
static void
runLater
(JsRunnable task) void
timeout
(int wait)
-
Constructor Details
-
LazyPromise
public LazyPromise()
-
-
Method Details
-
ofObject
-
asPromise
- Parameters:
timeout
- How many millis to wait until failing the promise with a timeout.- Returns:
- a real promise that we will resolve when we are resolved.
This method overload is not strictly necessary to call when explicitly wiring up failure handling for
this LazyPromise which you can guarantee will be eventually called.
To create a promise without a timeout, see
asPromise()
.
-
asPromise
- Returns:
- a real promise that we will resolve when we are resolved.
Use this method if you are safely wiring up failure handling for this LazyPromise. If you aren't
explicitly wiring up calls to
fail(Object)
this LazyPromise, then you should setup a timeout (seeasPromise(int)
andtimeout(int)
-
isUnresolved
public boolean isUnresolved() -
isResolved
public boolean isResolved() -
isFailure
public boolean isFailure() -
isSuccess
public boolean isSuccess() -
isFulfilled
public boolean isFulfilled() -
fail
-
succeed
-
promiseLater
public static <T> elemental2.promise.Promise<T> promiseLater(T table) Create a deferred promise from a known value. Rather than resolve immediately, this forces asynchronicity, to give the calling code time to unwind its stack before running. -
reject
-
timeout
-
asCallback
-