List
List
The List module is responsible for storing, getting and removing values inside a list. Its methods can be accessed as shown in the example below:
const lista = List.create["v1_0_0"]()
Methods
create
Method responsible for creating a new list.
const lista = List.create["v1_0_0"]()
Required parameters
- There are no required parameters.
Optional parameters
- There are no optional parameters.
Return
The constant or variable created, such as the lista of the example shown earlier, returns a value of the List type. The value of the List type has the following methods and properties:
lista.addItem(): Method responsible for adding a new item to the list.lista.getItem(): Method responsible for getting an item from the list.lista.removeItem(): Method responsible for removing an item from the list.lista.clear(): Method responsible for removing every item from the list.lista.size: Property responsible for getting the size of the list.lista.values: Property responsible for getting the values of the list.
addItem
Method responsible for adding an element to a given list.
const addList = await List.addList["v1_0_0"]({
list: lista,
value: 457
})
Required parameters
list: List - expects an instance of the List type obtained through the create method.value: Any - value that will be stored; it can be any value.
Optional parameters
key: String - expects a key to point to the value; if the field is not filled in, a random key is generated for the value.
Return
The constant or variable created, such as the addList of the example shown earlier, receives a value of the Object type that gives access to the following properties:
addList.key: String - returns the key of the value stored.addList.value: Any - returns the value stored.
removeItem
Method responsible for removing an element of a given list.
List.removeItem["v1_0_0"]({
list: lista,
key: addList.key
})
Required parameters
list: List - expects an instance of the List type obtained through the create method.key: String - expects the key of the item that will be removed from the list.
Return
This action has no return.
clear
Method responsible for removing every element of a given list.
List.clear["v1_0_0"]({
list: lista
})
Required parameters
list: List - expects an instance of the List type obtained through the create method.
Return
This action has no return.
getValue
Method responsible for getting a value of the list according to the key provided.
const getValue = actions.List.getValue["v1_0_0"]({
list: lista,
key: addList.key
})
Required parameters
list: List - expects an instance of the List type obtained through the create method.key: String - expects the key of the item you want to get from the list.
Return
The constant or variable created, such as the getValue of the example shown earlier, receives a value of the object type that gives access to the following properties:
getValue.key: String - returns the key of the value obtained by the method.getValue.value: Any - returns the value obtained by the method.
getAllValues
Method responsible for getting every value stored in a list.
const allValues = await List.getAllValues["v1_0_0"]({
list: lista
})
Required parameters
list: List - expects an instance of the List type obtained through the create method.
Return
The constant or variable created, such as the allValues of the example shown earlier, receives a value of the object type with the following property:
allValues.values: Any - returns all the values stored in the list, ornullif the list is empty.