ArrayProxy
Generic types: | P C |
Implements: |
ArrayLike<C> Iterable<C> |
This is an internal class used by
to wrap the field that represents the child array with a class that manages all the magic of loading the data from the server as it is accessed.
Note: The constructor of this class returns a Proxy to intercept property accesses. This is an intentional and necessary design choice to achieve the desired behavior of dynamically loading data.
See Also
Constructor
The constructor for the ArrayProxy class. | ||||||||||||
Presentation
| ||||||||||||
Parameters
|
Properties
Name | Type | Description |
---|---|---|
[isProxy] | boolean | |
childActionService |
| |
entityAdapter | EntityAdapter< | |
length implements ArrayLike | number | |
parentEntityAdapter | EntityAdapter< | |
rawArray | string[] |
Methods
[Symbol.iterator]()implements Iterable |
---|
Implements iterator so we can use methods that depend on iterable. |
Presentation
|
Returns |
addToStore()implements
| |||||||||
---|---|---|---|---|---|---|---|---|---|
This method allows us to add an item to the array. Make sure it contains and ID field and any other defaults you might need | |||||||||
Presentation
| |||||||||
Parameters
Returnsvoid |
getAtIndex() | ||||||
---|---|---|---|---|---|---|
Allows us to go after the data in the store based on the index of the array. | ||||||
Presentation
| ||||||
Parameters
Returns |
getIdAtIndex()implements
| ||||||
---|---|---|---|---|---|---|
returns the id at the given index, if the array is a virtual array, the id is returned without fetching from the server. | ||||||
Presentation
| ||||||
Parameters
Returnsstring | undefined -the id at the given index |
getServices() |
---|
grabs common actions and store used by other methods |
Presentation
|
Returns{ service: -the |
init() |
---|
This initialized the class once it has been created. We do this so that we can test the class without having to worry about executable code in the constructor. |
Presentation
|
Returnsvoid |
removeFromStore()implements
| |||||||||
---|---|---|---|---|---|---|---|---|---|
This removes a row from the store that was previously added, but not saved to the server yet. | |||||||||
Presentation
| |||||||||
Parameters
Returnsvoid |
toJSON() |
---|
This primarily exist for testing so you can stringify the array and then parse it so that you get an array you can compare against instead of an object of type ArrayProxy that you can't do much with. |
Presentation
|
Returns |