public class NodeList extends NodeFeature implements ReactiveValue
The list works as a reactive value with regards to its structure. A
Computation will get a dependency on this list for any read operation
that depends on the list structure, such as querying the length, iterating
the list or finding the index of an item. Accessing an item by index does not
create a dependency. The Computation is invalidated when items
are added, removed, reordered or replaced. It is not invalidated when the
contents of an item is updated since all items are expected to be either
immutable or reactive values of their own.
| Constructor and Description |
|---|
NodeList(int id,
StateNode node)
Creates a new list.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(int index,
Object item)
Shorthand for adding the given item at the given index.
|
elemental.events.EventRemover |
addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener)
Adds a listener that has a dependency to this value, and should be
notified when this value changes.
|
elemental.events.EventRemover |
addSpliceListener(ListSpliceListener listener)
Adds a listener that will be notified when the list structure changes.
|
void |
clear()
Removes all the nodes from the list.
|
elemental.json.JsonValue |
convert(Function<Object,elemental.json.JsonValue> converter)
Convert the feature values into a
JsonValue using provided
converter for the values stored in the feature (i.e. |
void |
forEach(JsCollections.ForEachCallback<Object> callback)
Iterates all values in this list.
|
Object |
get(int index)
Gets the item at the given index.
|
elemental.json.JsonValue |
getDebugJson()
Gets a JSON object representing the contents of this feature.
|
boolean |
hasBeenCleared()
Returns
true if the list instance has been cleared at some point. |
int |
length()
Gets the number of items in this list.
|
void |
set(int index,
Object value)
Sets the value at the given index.
|
void |
splice(int index,
int remove)
Removes a number of items at the given index.
|
void |
splice(int index,
int remove,
JsArray<?> add)
Removes and adds a number of items at the given index.
|
getAsDebugJson, getId, getNodepublic NodeList(int id,
StateNode node)
id - the id of the listnode - the node of the listpublic int length()
public Object get(int index)
index - the indexpublic void set(int index,
Object value)
index - the indexvalue - the value to setpublic void add(int index,
Object item)
splice(int, int, JsArray) which updates the list
contents and fires the appropriate event.index - the index where the item should be addeditem - the new item to addpublic void splice(int index,
int remove)
ListSpliceEvent to be fired.index - the index at which do do the operationremove - the number of items to removepublic void clear()
ListSpliceEvent to be fired, with
ListSpliceEvent.isClear() as true.public final void splice(int index,
int remove,
JsArray<?> add)
This causes a ListSpliceEvent to be fired.
index - the index at which do do the operationremove - the number of items to removeadd - an array of new items to addpublic elemental.json.JsonValue getDebugJson()
NodeFeaturegetDebugJson in class NodeFeaturepublic elemental.json.JsonValue convert(Function<Object,elemental.json.JsonValue> converter)
NodeFeatureJsonValue using provided
converter for the values stored in the feature (i.e. primitive
types, StateNodes).convert in class NodeFeatureconverter - converter to convert values stored in the featurepublic elemental.events.EventRemover addSpliceListener(ListSpliceListener listener)
listener - the list change listenerpublic elemental.events.EventRemover addReactiveValueChangeListener(ReactiveValueChangeListener reactiveValueChangeListener)
ReactiveValueaddReactiveValueChangeListener in interface ReactiveValuereactiveValueChangeListener - the listener to addpublic void forEach(JsCollections.ForEachCallback<Object> callback)
callback - the callback to invoke for each valuepublic boolean hasBeenCleared()
true if the list instance has been cleared at some point.true if the list instance has been clearedCopyright © 2000–2021 Vaadin Ltd. All rights reserved.