com.vaadin.hilla.signals.
Class Signal<T>
Direct Known Subclasses:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a read-only instance of the signal that rejects any attempt to modify the signal value.
protected abstract com.fasterxml.jackson.databind.node.ObjectNode
Creates a snapshot event reflecting the current state of the signal.
boolean
getId()
Returns the signal UUID.
Returns the signal value type.
int
hashCode()
protected abstract com.fasterxml.jackson.databind.node.ObjectNode
processEvent
(com.fasterxml.jackson.databind.node.ObjectNode event) Processes the event and updates the signal value if needed.
static void
setMapper
(com.fasterxml.jackson.databind.ObjectMapper mapper) Sets the object mapper to be used for JSON serialization in Signals.
void
submit
(com.fasterxml.jackson.databind.node.ObjectNode event) Submits an event to the signal and notifies subscribers about the change of the signal value.
reactor.core.publisher.Flux<com.fasterxml.jackson.databind.node.ObjectNode>
Subscribes to the signal.
reactor.core.publisher.Flux<com.fasterxml.jackson.databind.node.ObjectNode>
Subscribes to an internal child signal with a specific signal id.
-
Constructor Details
-
Signal
-
Signal
-
-
Method Details
-
getDelegate
-
getId
Returns the signal UUID.
Returns:
the id
-
getValueType
Returns the signal value type.
Returns:
the value type
-
subscribe
public reactor.core.publisher.Flux<com.fasterxml.jackson.databind.node.ObjectNode> subscribe()Subscribes to the signal.
Returns:
a Flux of JSON events
-
subscribe
public reactor.core.publisher.Flux<com.fasterxml.jackson.databind.node.ObjectNode> subscribe(String signalId) Subscribes to an internal child signal with a specific signal id.
Parameters:
signalId
- the internal signal idReturns:
a Flux of JSON events
-
submit
public void submit(com.fasterxml.jackson.databind.node.ObjectNode event) Submits an event to the signal and notifies subscribers about the change of the signal value.
Parameters:
event
- the event to submit -
createSnapshotEvent
protected abstract com.fasterxml.jackson.databind.node.ObjectNode createSnapshotEvent()Creates a snapshot event reflecting the current state of the signal.
Returns:
the snapshot event
-
processEvent
protected abstract com.fasterxml.jackson.databind.node.ObjectNode processEvent(com.fasterxml.jackson.databind.node.ObjectNode event) Processes the event and updates the signal value if needed. Note that this method is not thread-safe and should be called from a synchronized context.
Parameters:
event
- the event to processReturns:
true
if the event was successfully processed and the signal value was updated,false
otherwise. -
asReadonly
Returns a read-only instance of the signal that rejects any attempt to modify the signal value. The read-only signal, however, receives the same updates as the original signal does.
Returns:
the read-only signal
-
equals
-
hashCode
public int hashCode() -
setMapper
public static void setMapper(com.fasterxml.jackson.databind.ObjectMapper mapper) Sets the object mapper to be used for JSON serialization in Signals. This is helpful for testing purposes. If not set, the default Hilla endpoint object mapper is used.
Note: If a custom endpointMapperFactory bean defined using the
EndpointController.ENDPOINT_MAPPER_FACTORY_BEAN_QUALIFIER
qualifier, the mapper from that factory is used also in Signals, and there is no need to set it manually here.Parameters:
mapper
- the object mapper to be used in Signals
-