Class ObjectListWrapper<ItemType, LiteralType>

An ObjectListProxy that wraps any new items via a wrap callback before adding them to the target Lightning.types.ObjectList

Type Parameters

  • ItemType
  • LiteralType extends Record<string | number | symbol, unknown>

Hierarchy (View Summary)

Constructors

Accessors

  • get length(): number
  • Number of items in the ObjectList

    Returns number

Methods

  • Add object to the end of the ObjectList, transforming it to ItemType instances if necessary.

    Parameters

    Returns null

    Returns the ItemType instance that was added to the ObjectList, except if object is an array in which it will return null

    If object is:

    • An Object Literal (See: Utils.isObjectLiteral)...
      • It will be tranformed into an instantiated ItemType via createItem before being added to the ObjectList.
    • An array...
      • Each item of the Array will be recursively sent to a.
    • An ItemType...
      • It will be added directly to the ObjectList
  • Add object to the end of the ObjectList, transforming it to ItemType instances if necessary.

    Parameters

    Returns ItemType

    Returns the ItemType instance that was added to the ObjectList, except if object is an array in which it will return null

    If object is:

    • An Object Literal (See: Utils.isObjectLiteral)...
      • It will be tranformed into an instantiated ItemType via createItem before being added to the ObjectList.
    • An array...
      • Each item of the Array will be recursively sent to a.
    • An ItemType...
      • It will be added directly to the ObjectList
  • Overridable method that returns true (or 1) if object is a directly insertable item.

    Parameters

    • object: Record<string, unknown>

    Returns undefined | boolean | 1

    For example, ElementChildList overrides this to return true if the object is an instantiated Element.

    1 and undefined are included in the type union because of how ElementChildList already implemnents this.

  • Patch settings into the ObjectList

    Parameters

    Returns void

    If settings is:

    • An Object Literal (See: Lightning.Utils.isObjectLiteral)...
      • The keys of the Object Literal are treated as ref strings. Each key is looked up in the set of existing items:
        • If the object at the ref key already exists in the ObjectList:
          • If the new object is an instantiated ItemType
            • The existing object is replaced with the new object.
          • If the new object is an Object Literal
            • The new Object Literal is patched into the existing object
        • If it does not:
          • The new object is added to the end of the ObjectList, transforming any Object Literals with createItem beforehand.
    • An array:
      • The items of the ObjectList are replaced by the array:
        • Instantiated ItemList objects are used directly.
        • Object Literals are patched into any existing items (matched by their ref values)
        • Object Literals that don't match existing items are created via createItem.