Class NodeMap
java.lang.Object
com.vaadin.client.flow.nodefeature.NodeFeature
com.vaadin.client.flow.nodefeature.NodeMap
- All Implemented Interfaces:
ReactiveValue
A state node feature that structures data as a map.
The feature works as a reactive value with regards to the set of available
properties. A Computation will get a dependency on this feature by
iterating the properties. Accessing a property by name does not create a
dependency. The Computation is invalidated when a property is
added (properties are never removed). It is not invalidated when the value of
a property changes since the property is a reactive values of its own.
- Since:
- 1.0
- Author:
- Vaadin Ltd
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionelemental.events.EventRemoveraddPropertyAddListener(MapPropertyAddListener listener) Adds a listener that is informed whenever a new property is added to this map.elemental.events.EventRemoveraddReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener) Adds a listener that has a dependency to this value, and should be notified when this value changes.elemental.json.JsonValueConvert the feature values into aJsonValueusing providedconverterfor the values stored in the feature (i.e. primitive types, StateNodes).voidforEachProperty(JsMap.ForEachCallback<String, MapProperty> callback) Iterates all properties in this map.elemental.json.JsonValueGets a JSON object representing the contents of this feature.getProperty(String name) Gets the property with a given name, creating it if necessary.Gets all property names in this map.booleanhasPropertyValue(String name) Checks if the given property is present and has a value.Methods inherited from class com.vaadin.client.flow.nodefeature.NodeFeature
getAsDebugJson, getId, getNode
-
Constructor Details
-
NodeMap
Creates a new map feature.- Parameters:
id- the id of the featurenode- the node of the feature
-
-
Method Details
-
getProperty
Gets the property with a given name, creating it if necessary.A
MapPropertyAddEventis fired if a new property instance is created.- Parameters:
name- the name of the property- Returns:
- the property instance
-
hasPropertyValue
Checks if the given property is present and has a value.- Parameters:
name- the name of the property to check- Returns:
- true if the property exists and has a value, false otherwise
-
forEachProperty
Iterates all properties in this map.- Parameters:
callback- the callback to invoke for each property
-
getPropertyNames
Gets all property names in this map.- Returns:
- a list with the property names, never
null
-
getDebugJson
public elemental.json.JsonValue getDebugJson()Description copied from class:NodeFeatureGets a JSON object representing the contents of this feature. Only intended for debugging purposes.- Specified by:
getDebugJsonin classNodeFeature- Returns:
- a JSON representation
-
convert
Description copied from class:NodeFeatureConvert the feature values into aJsonValueusing providedconverterfor the values stored in the feature (i.e. primitive types, StateNodes).- Specified by:
convertin classNodeFeature- Parameters:
converter- converter to convert values stored in the feature- Returns:
- resulting converted value
-
addReactiveValueChangeListener
public elemental.events.EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener) Description copied from interface:ReactiveValueAdds a listener that has a dependency to this value, and should be notified when this value changes.- Specified by:
addReactiveValueChangeListenerin interfaceReactiveValue- Parameters:
reactiveValueChangeListener- the listener to add- Returns:
- an event remover that can be used for removing the added listener
-
addPropertyAddListener
Adds a listener that is informed whenever a new property is added to this map.- Parameters:
listener- the property add listener- Returns:
- an event remover that can be used for removing the added listener
-