The 'Transaction Collection' class manages transaction-based collections. This class provides the ability to apply transaction queues to collections and manage changes.

Hierarchy (view full)

Constructors

  • The creator of the class 'MetaRowCollection'. This class provides a collection to manage 'MetaRow' objects.

    Parameters

    • owner: object

      Owner object of this collection.

    Returns MetaRowCollection

Properties

_elemTypes: any[]

Defines the type constraints for the collection element.

_guid: string

Unique identifier of the object (GUID). Uniquely identifies the object.

_list: any[]

An array that stores a list of elements in a collection. This array contains actual data from the collection.

_owner: object

Owned object of the collection.

_transQueue: TransactionQueue

The object that manages the transaction queue. This queue is used to process transaction operations sequentially.

_type: Function

The generator function of the object. The function used when the object was created.

autoChanges: boolean

Indicates whether the automatic change feature is enabled. The default is set to 'false', and automatically sets whether or not the changes are applied.

count: number

Returns the number of elements in the current collection.

hasChanges: boolean

Indicates whether the collection has been changed. 'True' means that there are changes to the collection.

length: number

Returns the number of elements in the current collection.

_NS: string

Indicates the namespace.

'Meta'
_PARAM: []

List of parameters used for the constructor.

_UNION: []

List of implemented interfaces.

[IObject, IMarshal]

Methods

  • Gets the property descriptor for the specified index.

    Parameters

    • idx: number

      Index to get the property technician.

    Returns PropertyDescriptor

    Property technician for the specified index.

  • Generates an 'onAdd' event.

    Parameters

    • idx: number

      Index of the element to be added.

    • elem: any

      The element to add.

    Returns void

    BaseCollection#onAdd

  • Generates an 'onAdd' event.

    Parameters

    • idx: number

      Index of added elements.

    • elem: any

      Added element.

    Returns void

    BaseCollection#onAdded

  • Generates an 'onChanged' event.

    Parameters

    • idx: number

      Index of the changed element.

    • elem: any

      Changed element.

    Returns any

    BaseCollection#onChanged

  • Generates an 'onChanging' event.

    Parameters

    • idx: number

      Index of the element to be changed.

    • elem: any

      The element to be changed.

    Returns any

    BaseCollection#onChanging

  • Generates an 'onClear' event.

    Returns any

    BaseCollection#onClear

  • Generates an 'onCheared' event.

    Returns any

    BaseCollection#onCleared

  • Create an 'onRemove' event.

    Parameters

    • idx: number

      Index of the element to be deleted.

    • elem: any

    Returns void

    BaseCollection#onRemove

  • Generates an 'onRemoved' event.

    Parameters

    • idx: number

      Index of the element to be deleted.

    • elem: any

      The element to delete.

    Returns void

    BaseCollection#onRemoved

  • Deletes an element in a specified location in the collection. This method deletes the element by implementing the abstract method '_remove'. (Use template method patterns)

    Parameters

    • pos: number

      Index of the element to be deleted.

    Returns boolean

    This is a Boolean value that indicates whether deletion is successful or not.

    const success = myCollection._remove(0);
    console.log(`Delete element successful: ${success}`);
  • Parameters

    • elem: any
    • Optionaldesc: PropertyDescriptor

    Returns number

  • Add the 'MetaRow' object to the collection.

    Parameters

    • row: MetaRow

      'MetaRow' object to be added.

    • OptionalisCheck: boolean

      Specifies whether to perform a validation; the default is 'false'.

    Returns number

    Index of the added 'MetaRow' object.

  • Initializes all elements of the collection. The collection is empty, and all elements are deleted.

    Returns void

  • Commit to reflect changes to the collection. This method applies all operations in the transaction queue.

    Returns void

  • Verify that the element exists in the collection.

    Parameters

    • elem: any

      This is the element to check.

    Returns boolean

    This is a Boolean value indicating the presence or absence of an element.

    const exists = myCollection.contains(someElement);
    console.log(`element exists: ${exists}`);
  • Compare the current object with the specified object.

    Parameters

    • target: object

      the object to be compared to.

    Returns boolean

    Returns whether the two objects are the same.

  • Test that all elements pass the test implemented with the provided function.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns boolean

    True if you return a true value for all array elements, otherwise false.

  • Filter only to elements that have passed the test implemented by the provided function

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다.(currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns any[]

    Returns a new array of results.

  • Returns the first element that satisfies the provided test function

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      This is the callback function. (currentValue, index, array) => any

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns any

    The first element in the array that satisfies the test function. If no element satisfies the test function, undefined is returned.

  • Returns the first element that satisfies the provided test function

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function. Index of the first element that passes the @returns{number} test. If no match exists, return -1.

    Returns any

  • Run the function provided for each element once.

    Parameters

    • callback: ((value: any, index: number, array: this) => void)

      This is the callback function. (currentValue, index, array) => void

        • (value, index, array): void
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns void

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns void

  • Converts the current 'TransactionCollection' object to a serialized object. In the serialization process, the cyclic reference is replaced by the value '$ref'.

    Parameters

    • OptionalvOpt: number

      Specifies the serialization option.

      • '0': Convert to a reference structure (including '_guid' and '$ref')
      • '1': Converting to a redundant structure (including '_guid' and '$ref')
      • '2': Conversion to non-coordinated structure (excluding '_guid' and '$ref')
    • Optionalowned: object | object[]

      The parent objects that currently own the object. You can receive an object or array of objects.

    Returns object

    Serialized object.

    const serialized = collection.getObject(2); // import serialized objects in a non-coordinated structure
    
  • Returns the creators of the current object and all the creators of the prototype chain to the array.

    Returns Function[]

    Returns the array of generator functions.

    const types = obj.getTypes();
    console.log(types); // [Function: MetaObject]
  • Look up an element in the collection.

    Parameters

    • Optionalelem: any

      The element to look up.

    Returns number

    Index of element. If element does not exist, return -1.

    const index = myCollection.indexOf(someElement);
    console.log (index of element: ${index});
  • Parameters

    • pos: number
    • elem: any
    • Optionaldesc: PropertyDescriptor

    Returns boolean

  • Insert the 'MetaRow' object at the specified location in the collection.

    Parameters

    • pos: number

      Index of the location where the 'MetaRow' object is to be inserted.

    • row: MetaRow

      'MetaRow' object to insert.

    • OptionalisCheck: boolean

      Specifies whether to perform a validation; the default is 'false'.

    Returns boolean

    Indicates whether the insertion is successful or not.

  • Verify that the current object is an instance of the specified type (including _UNION)

    Parameters

    • target: string | object

      The type of object to be checked (object or string).

    Returns boolean

    Returns whether it is an instance of the specified type.

  • Collects the results of calling a given function for each element and returns a new array.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      This is the callback function (currentValue, index, array) => any[]

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns any[]

    Returns a new array of results.

  • Run the given reducer function for each element and return one result.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (accumulator, currentValue, index, array) => any

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalinitialValue: any

      Use the first element of the array if it does not provide an initial value.

    Returns any

    Returns a new array of results.

  • Delete an element in the collection.

    Parameters

    • elem: any

      The element to delete.

    Returns number

    Index of deleted elements.

    const removedIndex = myCollection.remove(someElement);
    console.log(`Index of deleted element: ${removedIndex}`);
  • Deletes an element from the specified location.

    Parameters

    • pos: number

      The index location of the element to be deleted.

    Returns boolean

    This is the value of 'boolean' indicating successful deletion, 'true' if deletion is successful, and 'false' if it fails.

    const success = collection.removeAt(2); // delete element of index 2
    
  • Rolls back changes to the collection to the previous state. This method cancels all operations in the transaction queue.

    Returns void

  • Sets the serialized object to the current 'Transaction Collection' object. During this process, the object is initialized.

    Parameters

    • oGuid: object

      object of serialized GUID type.

    • Optionalorigin: object

      This is the original object that sets the current object. Default is 'oGuid'.

    Returns any

    collection.setObject(serializedObject); // Set serialized objects to the current collection
    
  • Test that at least one element passes through a given discriminant function.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns boolean

    Returns true if you return a true value for one element, or false.

Events

onAdd: ((idx: number, elem: any, _this: object) => void)

Events that occur before adding an element to a collection.

BaseCollection#onAdd

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of the element to be added.

      • elem: any

        The element to add.

      • _this: object

        current collection object.

      Returns void

myCollection.onAdd = function(idx, elem, _this) {
console.log(`Before adding elements: index ${idx}, element ${elem}`);
};
onAdded: ((idx: number, elem: any, _this: object) => void)

Events that occur after you add an element to a collection.

BaseCollection#onAdded

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of added elements.

      • elem: any

        Added element.

      • _this: object

        current collection object.

      Returns void

myCollection.onAdded = function(idx, elem, _this) {
console.log ('After adding elements: index ${idx}, element ${elem}');
};
onChanged: ((idx: number, elem: any, _this: object) => void)

Events that occur after you change an element in a collection.

BaseCollection#onChanged

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of the changed element.

      • elem: any

        Changed element.

      • _this: object

        current collection object.

      Returns void

myCollection.onChanged = function(idx, elem, _this) {
console.log ('After element change: index ${idx}, element ${elem}');
};
onChanging: ((idx: number, elem: any, _this: object) => void)

An event that occurs before you change an element in a collection.

BaseCollection#onChanging

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of the element to be changed.

      • elem: any

        The element to be changed.

      • _this: object

        current collection object.

      Returns void

myCollection.onChanging = function(idx, elem, _this) {
console.log(`Before element change: index ${idx}, element ${elem}`);
};
onClear: ((_this: object) => {})

Events that occur before the collection is initialized.

BaseCollection#onClear

Type declaration

    • (_this): {}
    • Parameters

      • _this: object

        current collection object.

      Returns {}

    myCollection.onClear = function(_this) {
    console.log ('Before collection initialization);
    };
    onCleared: ((_this: object) => {})

    Events that occur after the collection is initialized.

    BaseCollection#onCleared

    Type declaration

      • (_this): {}
      • Parameters

        • _this: object

          current collection object.

        Returns {}

      myCollection.onCleared = function(_this) {
      console.log ('After collection initialization');
      };
      onRemove: ((idx: number, elem: any, _this: object) => void)

      An event that occurs before an element is deleted from the collection.

      BaseCollection#onRemove

      Type declaration

        • (idx, elem, _this): void
        • Parameters

          • idx: number

            Index of the element to be deleted.

          • elem: any

            The element to delete.

          • _this: object

            current collection object.

          Returns void

      myCollection.onRemove = function(idx, elem, _this) {
      console.log(`Before element deletion: index ${idx}, element ${elem}`);
      };
      onRemoved: ((idx: number, elem: any, _this: object) => void)

      Events that occur after you delete an element from a collection.

      BaseCollection#onRemoved

      Type declaration

        • (idx, elem, _this): void
        • Parameters

          • idx: number

            Index of deleted elements.

          • elem: any

            Deleted element.

          • _this: object

            current collection object.

          Returns void

      myCollection.onRemoved = function(idx, elem, _this) {
      console.log(`After element deletion: index ${idx}, element ${elem}`);
      };