Class SignalOperation<T extends @Nullable Object>

java.lang.Object
com.vaadin.flow.signals.operations.SignalOperation<T>
Type Parameters:
T - the result type
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
CancelableOperation, InsertOperation, TransactionOperation

public class SignalOperation<T extends @Nullable Object> extends Object implements Serializable
An operation triggered on a signal instance. The result will be populated when the operation has been confirmed. The type of the result depends on the operation type.
See Also:
  • Constructor Details

    • SignalOperation

      public SignalOperation()
      Creates a new signal operation that will get a result later.
    • SignalOperation

      public SignalOperation(SignalOperation.ResultOrError<T> resultOrError)
      Creates a new signal operation that already has a result.
      Parameters:
      resultOrError - the result of the operation, not null
  • Method Details

    • result

      Gets the eventual operation result.
      Returns:
      a completable future with the operation result, not null
    • map

      public <R> SignalOperation<R> map(SerializableFunction<T,R> mapper)
      Creates a new operation that transforms the result value using the given mapper function. If this operation fails, the mapped operation will also fail with the same error.
      Type Parameters:
      R - the mapped result type
      Parameters:
      mapper - the function to transform the result value, not null
      Returns:
      a new operation with the mapped result, not null
    • forwardMappedResult

      protected <R> void forwardMappedResult(SignalOperation<R> target, SerializableFunction<T,R> mapper)
      Forwards the result of this operation to another operation after applying the mapper function. If this operation fails, the target operation will also fail with the same error.
      Type Parameters:
      R - the mapped result type
      Parameters:
      target - the operation to forward the result to, not null
      mapper - the function to transform the result value, not null