Package com.vaadin.signals
Interface WritableSignal<T>
- Type Parameters:
T- the signal value type
- All Superinterfaces:
Signal<T>
- All Known Implementing Classes:
NumberSignal,ReferenceSignal,ValueSignal
A signal to which a new value can be directly written.
-
Method Summary
Modifier and TypeMethodDescriptionWraps this signal to not accept changes.Sets the value of this signal if and only if the signal has the expected value at the time when the operation is confirmed.update(UnaryOperator<T> updater) Updates the signal value based on the given callback.Sets the value of this signal.
-
Method Details
-
value
Sets the value of this signal. The result of the returned operation will be resolved with the previous value at the time when this operation was confirmed.- Parameters:
value- the value to set- Returns:
- an operation containing the eventual result
-
replace
Sets the value of this signal if and only if the signal has the expected value at the time when the operation is confirmed. This is the signal counterpart toAtomicReference.compareAndSet(Object, Object). The result of the returned operation will be resolved as successful if the expected value was present and resolved as unsuccessful if any other value was present when the operation is processed.- Parameters:
expectedValue- the expected valuenewValue- the new value- Returns:
- an operation containing the eventual result
-
update
Updates the signal value based on the given callback. The callback receives the current signal value and returns the new value to use. If the original value has changed by the time this change is confirmed, then the returned value is ignored and the callback is run again with the new value as input. This process is repeated until cancelled or until the update succeeds without conflicting changes.The process can be cancelled through the returned operation instance. Note that canceling will only prevent further retries but the change will still be made if the currently running attempt succeeds.
The result of the returned operation will be resolved with the previous value at the time when a successful update operation was confirmed.
Update operations cannot participate in transactions since any retry would occur after the original transaction has already been committed. For this reason, the whole operation completely bypasses all transaction handling.
- Parameters:
updater- the value update callback, notnull- Returns:
- an operation containing the eventual result
-
asReadonly
Wraps this signal to not accept changes.This signal will keep its current configuration and changes applied through this instance will be visible through the wrapped instance.
- Returns:
- the new readonly signal, not
null
-