Internal API / Class

BaseArrayProxy

Generic types:P C
Implements:SmartArray<P, C>ArrayLike<C>Iterable<C>

This is an internal class used by createSmartSelector 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 BaseArrayProxy class.

Presentation
constructor(
	protected childArray: string[] | BaseArrayProxy<P, C>, 
	protected child: EntityState<C>, 
	protected childDefinition: BaseChildDefinition<P>
): BaseArrayProxy<P, C>;
Parameters
NameTypeDescription
p
childArray
string[] | BaseArrayProxy<P, C>

The ArrayProxyClassic or string[] of ids to wrap

p
child
EntityState<C>

The child EntityState we use to find the item in the store

p
childDefinition
BaseChildDefinition<P>

The ChildDefinition that allows us to get at features, entities and other things we need.

Properties

NameTypeDescription
[isProxy]
boolean
childActionService
FacadeBase<C>
childEntity
string
childFeature
string
length
implements ArrayLike
number
parentEntity
string
parentFeature
string
parentField
keyof P
parentSelectId
(this: void, row: SmartNgRXRowBase) => string
rawArray
string[]
selectId
(this: void, row: SmartNgRXRowBase) => string

Methods

[Symbol.iterator]()

implements Iterable

Implements iterator so we can use methods that depend on iterable.

@yields The next item in the iteration.

Presentation
[Symbol.iterator](): Iterator<C & RowProxyDelete, any, undefined>;
Returns
Iterator<C & RowProxyDelete, any, undefined> -

The next item in the iteration.

add()

implements SmartArray

This method allows us to add an item directly to the server. make sure it contains all the required fields for the row and the ID is supplied for thisRow you might need

Presentation
add(newRow: C, parentRow: P): void;
Parameters
NameTypeDescription
newRow
C

the item to add to the array

parentRow
P

the parent entity (this row) that contains the array

Returns
void

addToStore()

implements SmartArray

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
addToStore(newRow: C, thisRow: P): void;
Parameters
NameTypeDescription
newRow
C

the item to add to the array

thisRow
P

the parent entity (this row) that contains the array

Returns
void

getAtIndex()

Allows us to go after the data in the store based on the index of the array.

Presentation
getAtIndex(index: number): C & RowProxyDelete;
Parameters
NameTypeDescription
index
number

the index into the rawArray that has the ID we will lookup in the entity.

Returns
C & RowProxyDelete -

the item from the store or the default row if it is not in the store yet.

getIdAtIndex()

implements SmartArray

returns the id at the given index, if the array is a virtual array, the id is returned without fetching from the server.

Presentation
getIdAtIndex(index: number): string | undefined;
Parameters
NameTypeDescription
index
number

the index to get the id at

Returns
string | undefined -

the id at the given index

getServices()

grabs common actions and store used by other methods

Presentation
getServices(): { service: FacadeBase<C>; parentService: FacadeBase<P>; };
Returns
{ service: FacadeBase<C>; parentService: FacadeBase<P>; } -

the ActionService for the child and the parent

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
init(): void;
Returns
void
protected

removeChildIdFromChildArray()

Removes a child id from the child array of the parent. This is called from removeFromStore.

Presentation
protected removeChildIdFromChildArray(entity: EntityState<P>, parentId: string, parentField: keyof P, childId: string): void;
Parameters
NameTypeDescription
entity
EntityState<P>

The parent entity.

parentId
string

The id of the parent.

parentField
keyof P

The field of the parent that holds the child ids.

childId
string

The id of the child to remove.

Returns
void
abstract

removeFromStore()

implements SmartArray

This removes a row from the store that was previously added, but not saved to the server yet.

Presentation
abstract removeFromStore(row: C, parent: P): void;
Parameters
NameTypeDescription
row
C

the row to remove from the array

parent
P

the parent entity that contains the array

Returns
void
Overload #1

This removes a row from the store that was previously added, but not saved to the server yet.

Presentation
abstract removeFromStore(row: C, parent: P): void;
Parameters
NameTypeDescription
row
C

the row to remove from the array

parent
P

the parent entity that contains the array

Returns
void

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
toJSON(): (C & RowProxyDelete)[];
Returns
(C & RowProxyDelete)[] -

what this would return if it were a real array. Mostly for unit testing.