public interface JsFunction extends JsObject
IllegalStateException
.Modifier and Type | Method and Description |
---|---|
<T> T |
invoke(JsObject object,
java.lang.Object... args)
Invokes this function on the given
object with the specified args . |
<T> java.util.concurrent.CompletableFuture<T> |
invokeAsync(JsObject object,
java.lang.Object... args)
Invokes this function on the given
object with the specified args . |
call, close, frame, hasProperty, ownPropertyNames, property, propertyNames, putProperty, removeProperty
<T> T invoke(@Nullable JsObject object, java.lang.Object... args)
object
with the specified args
. This
method blocks the current thread until the function finishes its execution. If the function
raises an exception, then a JsException
with an error message that describes the
exception reason will be thrown. The same error message will be printed to the JavaScript
console.
The rules to convert Java types into JavaScript types and vice versa are the same as for
the JsObject.call(String, Object...)
method.
T
- the result of the JavaScript function executionobject
- the JavaScript object to invoke this function on. Pass null
to invoke
the function as a global function.args
- the list of input argumentsJsException
- when an error occurs during the function executionjava.lang.IllegalArgumentException
- when args
contains an unsupported typeObjectClosedException
- when the JavaScript object is already disposed or invalid<T> java.util.concurrent.CompletableFuture<T> invokeAsync(@Nullable JsObject object, java.lang.Object... args)
object
with the specified args
.
This method does not block the current thread execution and executes the function asynchronously.
Returns a new CompletableFuture
that is completed when the function finishes its
execution. If the function throws an exception, the future is completed with
JsException
with the same error message that will be printed to the JavaScript
console. If the browser is closed during the function execution, the future will be canceled.
T
- the result of the JavaScript function executionobject
- the JavaScript object to invoke this function on. Pass null
to invoke
the function as a global function.args
- the list of input argumentsjava.lang.IllegalArgumentException
- when args
contains an unsupported typeObjectClosedException
- when the JavaScript object is already disposed or invalid