ActiveListContent<T>

CLASS

Represents a piece of content in the contents array of the ActiveList.

The purpose of the ActiveListContent is to act as a wrapper around the value which is actually in the contents array. It knows things like whether the item is active or not.

It also contains methods to activate, remove, swap and move itself within the ActiveList.

Since 1.0.0

Constructor

Creates an ActiveListContent which belongs to the given ActiveList.

Note: you should never create instances of ActiveListContent yourself. You are supposed to let ActiveList do this for you.

Since 1.0.0

Signature

constructor(
activeList : ActiveList<T> ,
index : number ,
value : T
): ActiveListContent<T>

Parameters

activeList: ActiveList<T>

The ActiveList this ActiveListContent belongs to.

index: number

The index of this ActiveListContent within the ActiveList.

value: T

The value this ActiveListContent wraps.

Properties

  • activeList

    ActiveList<T>

    Reference to the ActiveList is it a part of.

    Since 1.0.0

  • hasBeenActiveBefore

    boolean

    Whether or not the ActiveListContent has been active at least once in the past.

    Since 1.0.0

  • hasNext

    boolean

    Whether this ActiveListContent has at least one other ActiveListContent coming after it in the contents

    Since 1.0.0

  • hasPrevious

    boolean

    Whether this ActiveListContent has at least one other ActiveListContent coming before it in the contents.

    Since 1.0.0

  • index

    number

    The index of the ActiveListContent which it has within the contents.

    Since 1.0.0

  • isActive

    boolean

    Whether or not the ActiveListContent is currently active.

    Since 1.0.0

  • isFirst

    boolean

    Whether or not the ActiveListContent is considered to be the first item in the contents.

    Since 1.0.0

  • isLast

    boolean

    Whether or not the ActiveListContent is considered to be the last item in the contents.

    Since 1.0.0

  • isNext

    boolean

    Whether this ActiveListContent comes directly after the ActiveListContent, in the contents array, which is currently the lastActiveList.

    Since 1.0.0

  • isPrevious

    boolean

    Whether this ActiveListContent comes directly before the ActiveListContent, in the contents array, which is currently the lastActiveList.

    Since 1.0.0

  • value

    T

    The actual value of the ActiveListContent it can be whatever the developer wants it to be.

    Since 1.0.0

Methods

  • activate

    When calling activate it will make this ActiveListContent active.

    Since 1.0.0

    Signature

    activate(
    activationOptions : ActiveListActivationOptions<T>
    ): void

    Parameters

    activationOptions: ActiveListActivationOptions<T>

    The activation options

  • deactivate

    When calling deactivate it will make this ActiveListContent inactive.

    Since 1.0.0

    Signature

    deactivate(
    activationOptions : ActiveListActivationOptions<T>
    ): void

    Parameters

    activationOptions: ActiveListActivationOptions<T>

    The activation options

  • moveToFirst

    Moves the ActiveListContent to the first position in the contents array.

    Note: if the active ActiveListContent is moved it will stay active, meaning that the activeIndex will get updated.

    Since 1.0.0

    Signature

    moveToFirst(): void
  • moveToIndex

    Moves the ActiveListContent to the position at index "to".

    It is possible to move the ActiveListContent to the last place by making the "to" index the length of the contents array.

    Note: if the active ActiveListContent is moved it will stay active, meaning that the activeIndex will get updated.

    Since 1.0.0

    Signature

    moveToIndex(
    to : number
    ): void

    Parameters

    to: number

    The location the from needs to move "to".

    Throws

    ActiveListIndexOutOfBoundsError Index out of bounds error.

  • moveToLast

    Moves the ActiveListContent to the last position in the contents array.

    Note: if the active ActiveListContent is moved it will stay active, meaning that the activeIndex will get updated.

    Since 1.0.0

    Signature

    moveToLast(): void
  • moveToPredicate

    Moves the ActiveListContent to the position of the item for which the predicate returns true.

    If no item matches the predicate nothing is moved.

    The position to where the ActiveListContent is inserted can be altered by providing a mode:

    1. When the mode is 'at', the ActiveListContent is inserted to the position where the predicate matches. This is the default mode.
    2. When the mode is 'after', the ActiveListContent is inserted to after the position where the predicate matches.
    3. When the mode is 'before', the ActiveListContent is inserted to before the position where the predicate matches.

    Since 1.0.0

    Signature

    moveToPredicate( ): void

    Parameters

    predicate: ActiveListContentPredicate<T>

    The predicate function which when true is returned moves the item to after that position.

    options: ActiveListPredicateOptions

    The options for the predicate, when no options are provided the mode will default to "at".

  • remove

    When calling remove it will remove this ActiveListContent, and return the value the ActiveListContent held.

    Since 1.0.0

    Signature

    remove(): T

    Returns

    The removed value

  • swapWith

    Swaps the ActiveListContent with the ActiveListContent at the given index.

    Note: if the active ActiveListContent is swapped, it will stay active, it will only get a new position.

    Since 1.0.0

    Signature

    swapWith(
    item : T
    ): void

    Parameters

    item: T

    Throws

    ActiveListItemNotFoundError Item not found error

  • swapWithByIndex

    Swaps the ActiveListContent with the ActiveListContent at the given index.

    Note: if the active ActiveListContent is swapped, it will stay active, it will only get a new position.

    Since 1.0.0

    Signature

    swapWithByIndex(
    index : number
    ): void

    Parameters

    index: number

    Throws

    ActiveListIndexOutOfBoundsError Index out of bounds error.

  • swapWithNext

    Swaps the ActiveListContent with the next ActiveListContent in the sequence.

    If isCircular of the ActiveList is true swapping whilst on the last index will make this ActiveListContent swap with the first index. If isCircular is false it will do nothing, and keep the ActiveListContent on the last index.

    Note: if the active ActiveListContent is swapped, it will stay active, it will only get a new position.

    Since 1.0.0

    Signature

    swapWithNext(): void
  • swapWithPrevious

    Swaps the ActiveListContent with the previous ActiveListContent in the sequence.

    If isCircular of the ActiveList is true swapping whilst on the first index will make this ActiveListContent swap with the last index. If isCircular is false it will do nothing, and keep the ActiveListContent on the first index.

    Note: if the active ActiveListContent is swapped, it will stay active, it will only get a new position.

    Since 1.0.0

    Signature

    swapWithPrevious(): void
  • toggle

    When calling toggle it will flip the this ActiveListContent isActive state.

    So when isActive is true and toggle is called, isActive will become false. When isActive is false and toggle is called, isActive will become true.

    With the activationOptions you can determine the effects on cooldown and autoPlay.

    Since 1.0.0

    Signature

    toggle(
    activationOptions : ActiveListActivationOptions<T>
    ): void

    Parameters

    activationOptions: ActiveListActivationOptions<T>

    The activation options