Class JsPromise
java.lang.Object
org.vaadin.firitin.util.JsPromise
Deprecated, for removal: This API element is subject to removal in a future version.
Vaadin core should support everything this does these days.
Helper methods to consume asynchronous JS APIs without extra JS
trickery. The given script bodies are executed on the UI element
and wrapped into a promise, either using Promise with resolve
and reject exposed to your script body or using an anonymous
async function.
-
Constructor Summary
ConstructorsConstructorDescriptionDeprecated, for removal: This API element is subject to removal in a future version. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> CompletableFuture<T> compute(String asyncMethodBody, Class<T> returnType, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<Boolean> computeBoolean(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<Double> computeDouble(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<Integer> computeInteger(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<String> computeString(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static <T> CompletableFuture<T> resolve(String promiseBody, Class<T> returnType, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<Boolean> resolveBoolean(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<Double> resolveDouble(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<Integer> resolveInteger(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.static CompletableFuture<String> resolveString(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.
-
Constructor Details
-
JsPromise
public JsPromise()Deprecated, for removal: This API element is subject to removal in a future version.
-
-
Method Details
-
resolveString
@Deprecated(forRemoval=true) public static CompletableFuture<String> resolveString(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Asynchronously returns a string from the client side. The JS given for this method is a JS Promise body with "resolve" and "reject" defined for returning the value or failing the request.- Parameters:
promiseBody- a JS snippet that resolves a promiseargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the string as
CompletableFuture
-
computeString
@Deprecated(forRemoval=true) public static CompletableFuture<String> computeString(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Executes given JS snippet in an async method, making it possible to use "await" keyword to consume promises in an easier way. The return value is passed back to the server side as aCompletableFuture.- Parameters:
asyncMethodBody- the JS method bodyargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the future to get the value
-
computeInteger
@Deprecated(forRemoval=true) public static CompletableFuture<Integer> computeInteger(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Executes given JS snippet in an async method, making it possible to use "await" keyword to consume promises in an easier way. The return value is passed back to the server side as aCompletableFuture.- Parameters:
asyncMethodBody- the JS method bodyargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the future to get the value
-
computeDouble
@Deprecated(forRemoval=true) public static CompletableFuture<Double> computeDouble(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Executes given JS snippet in an async method, making it possible to use "await" keyword to consume promises in an easier way. The return value is passed back to the server side as aCompletableFuture.- Parameters:
asyncMethodBody- the JS method bodyargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the future to get the value
-
computeBoolean
@Deprecated(forRemoval=true) public static CompletableFuture<Boolean> computeBoolean(String asyncMethodBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Executes given JS snippet in an async method, making it possible to use "await" keyword to consume promises in an easier way. The return value is passed back to the server side as aCompletableFuture.- Parameters:
asyncMethodBody- the JS method bodyargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the future to get the value
-
resolveBoolean
@Deprecated(forRemoval=true) public static CompletableFuture<Boolean> resolveBoolean(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Asynchronously returns a boolean from the client side. The JS given for this method is a JS Promise body with "resolve" and "reject" defined for returning the value or failing the request.- Parameters:
promiseBody- a JS snippet that resolves a promiseargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the boolean as
CompletableFuture
-
resolveInteger
@Deprecated(forRemoval=true) public static CompletableFuture<Integer> resolveInteger(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Asynchronously returns an integer from the client side. The JS given for this method is a JS Promise body with "resolve" and "reject" defined for returning the value or failing the request.- Parameters:
promiseBody- a JS snippet that resolves a promiseargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the integer as
CompletableFuture
-
resolveDouble
@Deprecated(forRemoval=true) public static CompletableFuture<Double> resolveDouble(String promiseBody, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Asynchronously returns a double from the client side. The JS given for this method is a JS Promise body with "resolve" and "reject" defined for returning the value or failing the request.- Parameters:
promiseBody- a JS snippet that resolves a promiseargs- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the double as
CompletableFuture
-
resolve
@Deprecated(forRemoval=true) public static <T> CompletableFuture<T> resolve(String promiseBody, Class<T> returnType, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Asynchronously returns a value from the client side. The JS given for this method is a JS Promise body with "resolve" and "reject" defined for returning the value or failing the request.- Type Parameters:
T- the return type, if not a basic data type, the return parameter in browser is expected to be JSON that is then mapped to given type with Jackson- Parameters:
promiseBody- a JS snippet that resolves a promisereturnType- the return value type: String, Integer, Double, Boolean or an object that gets serialized to JSON and deserialized with default Jackson settings on the server side.args- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the future to get the value
-
compute
@Deprecated(forRemoval=true) public static <T> CompletableFuture<T> compute(String asyncMethodBody, Class<T> returnType, Serializable... args) Deprecated, for removal: This API element is subject to removal in a future version.Executes given JS snippet wrapped in an async method, making it possible to use "await" keyword to consume promises in an easier way. Once resolved, the return value is passed back to the server in aCompletableFuture.- Type Parameters:
T- the return type, if not a basic data type, the return parameter in browser is expected to be JSON that is then mapped to given type with Jackson- Parameters:
asyncMethodBody- the JS method bodyreturnType- the return value type: String, Integer, Double, Boolean or an object that gets serialized to JSON and deserialized with default Jackson settings on the server side.args- the extra arguments interpolated into JS as in Element.executeJs- Returns:
- the future to get the value
-