Class ReturnChannelMap
- All Implemented Interfaces:
Serializable
Return channels are only tracked on the server. The client doesn't need to know which channels are registered - it only passes the channel id back to the server. The server checks that the received channel id is (still) valid and logs a warning if it isn't.
For internal use only. May be renamed or removed in a future release.
- Since:
- 2.0
- Author:
- Vaadin Ltd
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionReturnChannelMap(StateNode node) Creates a new return channel map for the given state node. -
Method Summary
Modifier and TypeMethodDescriptionget(int channelId) Gets the return channel registration registered with the provided id, ornullif no channel is registered with that id.booleanReturn if map contains any registered channels.registerChannel(SerializableBiConsumer<tools.jackson.databind.node.ArrayNode, ReturnChannelRegistration> handler) Registers a new channel based on a callback that receives the provided arguments and the channel registration when a message is passed to the channel.registerChannel(SerializableConsumer<tools.jackson.databind.node.ArrayNode> handler) Registers a new channel based on a callback that receives the provided arguments when a message is passed to the channel.Methods inherited from class com.vaadin.flow.internal.nodefeature.ServerSideFeature
collectChanges, forEachChild, generateChangesFromEmptyMethods inherited from class com.vaadin.flow.internal.nodefeature.NodeFeature
allowsChanges, attachPotentialChild, detatchPotentialChild, getNode, onAttach, onDetach
-
Constructor Details
-
ReturnChannelMap
Creates a new return channel map for the given state node.- Parameters:
node- the owning state node, notnull
-
-
Method Details
-
registerChannel
public ReturnChannelRegistration registerChannel(SerializableConsumer<tools.jackson.databind.node.ArrayNode> handler) Registers a new channel based on a callback that receives the provided arguments when a message is passed to the channel.The returned registration can be passed to the client as a parameter to various
executeJavaScriptmethods. The client side representation of the registration will be a function that will send a message to the provided handler.- Parameters:
handler- the argument handler, notnull- Returns:
- a return channel registration
-
registerChannel
public ReturnChannelRegistration registerChannel(SerializableBiConsumer<tools.jackson.databind.node.ArrayNode, ReturnChannelRegistration> handler) Registers a new channel based on a callback that receives the provided arguments and the channel registration when a message is passed to the channel. The purpose of passing the registration to the handler is to allow the channel to unregister itself when it receives a message.The returned registration can be passed to the client as a parameter to various
executeJavaScriptmethods. The client side representation of the registration will be a function that will send a message to the provided handler.- Parameters:
handler- the argument and registration handler, notnull- Returns:
- a return channel registration
-
get
Gets the return channel registration registered with the provided id, ornullif no channel is registered with that id.- Parameters:
channelId- the channel id to look for- Returns:
- a return channel registration, or
nullif no registration exists for the given id
-
hasChannels
public boolean hasChannels()Return if map contains any registered channels.- Returns:
trueif registered channels exist.
-