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:
- Serialized Form
-
-
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 Instance Methods Concrete Methods Modifier and Type Method Description booleancancelExecution()Cancel the javascript execution, if it was not yet sent to the browser for execution.voidcomplete(elemental.json.JsonValue value)Completes this invocation with the given return value from the client.voidcompleteExceptionally(elemental.json.JsonValue value)Completes this invocation with the given exception value from the client.UIInternals.JavaScriptInvocationgetInvocation()Gets the underlying JavaScript invocation that this pending invocation is based on.StateNodegetOwner()Gets the state node that this invocation belongs to.booleanisCanceled()Checks whether this invocation has been canceled.booleanisSentToBrowser()Checks whether the JavaScript execution has already been sent to the browser.booleanisSubscribed()Checks if there are any subscribers for the return value of this expression.voidthen(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, notnullinvocation- 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:
trueif the return value should be passed back from the client,falseif 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:PendingJavaScriptResultCancel the javascript execution, if it was not yet sent to the browser for execution.- Specified by:
cancelExecutionin interfacePage.ExecutionCanceler- Specified by:
cancelExecutionin interfacePendingJavaScriptResult- Returns:
trueif the execution was canceled,falseif not
-
isSentToBrowser
public boolean isSentToBrowser()
Description copied from interface:PendingJavaScriptResultChecks 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:
isSentToBrowserin interfacePendingJavaScriptResult- Returns:
trueif the execution is sent to the browser,falseif it's still pending
-
then
public void then(SerializableConsumer<elemental.json.JsonValue> successHandler, SerializableConsumer<String> errorHandler)
Description copied from interface:PendingJavaScriptResultAdds 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:
thenin interfacePendingJavaScriptResult- Parameters:
successHandler- a handler for the JSON representation of the value from a successful execution, notnullerrorHandler- a handler for an error message in case the execution failed, ornullto ignore errors
-
isCanceled
public boolean isCanceled()
Checks whether this invocation has been canceled.- Returns:
trueif 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
-
-