Class ReturnChannelMap
- java.lang.Object
-
- com.vaadin.flow.internal.nodefeature.NodeFeature
-
- com.vaadin.flow.internal.nodefeature.ServerSideFeature
-
- com.vaadin.flow.internal.nodefeature.ReturnChannelMap
-
- All Implemented Interfaces:
Serializable
public class ReturnChannelMap extends ServerSideFeature
Server-side node feature that keeps track of the return channels registered for a state node.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:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description ReturnChannelMap(StateNode node)
Creates a new return channel map for the given state node.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ReturnChannelRegistration
get(int channelId)
Gets the return channel registration registered with the provided id, ornull
if no channel is registered with that id.boolean
hasChannels()
Return if map contains any registered channels.ReturnChannelRegistration
registerChannel(SerializableBiConsumer<elemental.json.JsonArray,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.ReturnChannelRegistration
registerChannel(SerializableConsumer<elemental.json.JsonArray> 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, generateChangesFromEmpty
-
Methods inherited from class com.vaadin.flow.internal.nodefeature.NodeFeature
allowsChanges, attachPotentialChild, detatchPotentialChild, getNode, onAttach, onDetach
-
-
-
-
Constructor Detail
-
ReturnChannelMap
public ReturnChannelMap(StateNode node)
Creates a new return channel map for the given state node.- Parameters:
node
- the owning state node, notnull
-
-
Method Detail
-
registerChannel
public ReturnChannelRegistration registerChannel(SerializableConsumer<elemental.json.JsonArray> 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
executeJavaScript
methods. 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<elemental.json.JsonArray,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
executeJavaScript
methods. 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
public ReturnChannelRegistration get(int channelId)
Gets the return channel registration registered with the provided id, ornull
if no channel is registered with that id.- Parameters:
channelId
- the channel id to look for- Returns:
- a return channel registration, or
null
if no registration exists for the given id
-
hasChannels
public boolean hasChannels()
Return if map contains any registered channels.- Returns:
true
if registered channels exist.
-
-