com.vaadin.flow.component.internal.
Class PendingJavaScriptInvocation
- java.lang.Object
-
- com.vaadin.flow.component.internal.PendingJavaScriptInvocation
-
All Implemented Interfaces:
Page.ExecutionCanceler
,PendingJavaScriptResult
,Serializable
public class PendingJavaScriptInvocation extends Object implements PendingJavaScriptResult
A pending JavaScript result that can be sent to the client.
For internal use only. May be renamed or removed in a future release.
Since:
2.0
See Also:
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.vaadin.flow.component.page.PendingJavaScriptResult
PendingJavaScriptResult.JavaScriptException
-
-
Constructor Summary
Constructors Constructor Description PendingJavaScriptInvocation(StateNode owner, UIInternals.JavaScriptInvocation invocation)
Creates a new pending invocation for the given owner node and invocation.
-
Method Summary
All Methods Modifier and Type Method Description boolean
cancelExecution()
Cancel the javascript execution, if it was not yet sent to the browser for execution.
void
complete(elemental.json.JsonValue value)
Completes this invocation with the given return value from the client.
void
completeExceptionally(elemental.json.JsonValue value)
Completes this invocation with the given exception value from the client.
UIInternals.JavaScriptInvocation
getInvocation()
Gets the underlying JavaScript invocation that this pending invocation is based on.
StateNode
getOwner()
Gets the state node that this invocation belongs to.
boolean
isCanceled()
Checks whether this invocation has been canceled.
boolean
isSentToBrowser()
Checks whether the JavaScript execution has already been sent to the browser.
boolean
isSubscribed()
Checks if there are any subscribers for the return value of this expression.
void
then(SerializableConsumer<elemental.json.JsonValue> successHandler, SerializableConsumer<String> errorHandler)
Adds an untyped handler that will be run for a successful execution and a handler that will be run for a failed execution.
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.vaadin.flow.component.page.PendingJavaScriptResult
then, then, then, toCompletableFuture, toCompletableFuture
-
-
-
-
Constructor Detail
-
PendingJavaScriptInvocation
public PendingJavaScriptInvocation(StateNode owner, UIInternals.JavaScriptInvocation invocation)
Creates a new pending invocation for the given owner node and invocation.
Parameters:
owner
- the state node that this invocation is related to, notnull
invocation
- the JavaScript invocation to send, notnull
-
-
Method Detail
-
getOwner
public StateNode getOwner()
Gets the state node that this invocation belongs to.
Returns:
the owner state node
-
isSubscribed
public boolean isSubscribed()
Checks if there are any subscribers for the return value of this expression.
Returns:
true
if the return value should be passed back from the client,false
if the return value can be ignored
-
complete
public void complete(elemental.json.JsonValue value)
Completes this invocation with the given return value from the client. Should only be used if there return value subscribers.
Parameters:
value
- the JSON return value from the client
-
completeExceptionally
public void completeExceptionally(elemental.json.JsonValue value)
Completes this invocation with the given exception value from the client. Should only be used if there return value subscribers.
Parameters:
value
- the JSON exception value from the client
-
cancelExecution
public boolean cancelExecution()
Description copied from interface:
PendingJavaScriptResult
Cancel the javascript execution, if it was not yet sent to the browser for execution.
Specified by:
cancelExecution
in interfacePage.ExecutionCanceler
Specified by:
cancelExecution
in interfacePendingJavaScriptResult
Returns:
true
if the execution was canceled,false
if not
-
isSentToBrowser
public boolean isSentToBrowser()
Description copied from interface:
PendingJavaScriptResult
Checks whether the JavaScript execution has already been sent to the browser. It is no longer possible to cancel the execution or add a handler for the result after the execution has been sent.
Specified by:
isSentToBrowser
in interfacePendingJavaScriptResult
Returns:
true
if the execution is sent to the browser,false
if it's still pending
-
then
public void then(SerializableConsumer<elemental.json.JsonValue> successHandler, SerializableConsumer<String> errorHandler)
Description copied from interface:
PendingJavaScriptResult
Adds an untyped handler that will be run for a successful execution and a handler that will be run for a failed execution. One of the handlers will be invoked asynchronously when the result of the execution is sent back to the server. It is not possible to synchronously wait for the result of the execution while holding the session lock since the request handling thread that makes the result available will also need to lock the session.
Handlers can only be added before the execution has been sent to the browser.
Specified by:
then
in interfacePendingJavaScriptResult
Parameters:
successHandler
- a handler for the JSON representation of the value from a successful execution, notnull
errorHandler
- a handler for an error message in case the execution failed, ornull
to ignore errors
-
isCanceled
public boolean isCanceled()
Checks whether this invocation has been canceled.
Returns:
true
if the invocation has been canceled, otherwisefalse
-
getInvocation
public UIInternals.JavaScriptInvocation getInvocation()
Gets the underlying JavaScript invocation that this pending invocation is based on.
Returns:
the JavaScript invocation, not
null
-
-