Skip to main content

ObservableSortedList

A list that can be observed for blend and other components and maintains sorting order.

This class is very expensive to use as it enforces maintaining order on the object. Each entries produces what is most likely 4-5 tables, and changing can result in O(n) table construction and deltas.

However, for small lists that don't change frequently, such as a global leaderboard, this can be a nice small interactive class.

For performance reasons this class defers firing events until the next defer() event frame.

This class always prefers to add equivalent elements to the end of the list if they're not in the list. Otherwise it prefers minimal movement.

Properties

ItemAdded

This item is read only and cannot be modified. Read Only
ObservableSortedList.ItemAdded: Signal<T,number,Symbol>

Fires when an item is added

ItemRemoved

This item is read only and cannot be modified. Read Only
ObservableSortedList.ItemRemoved: self._maid:Add(Signal<T,Symbol>)

Fires when an item is removed.

OrderChanged

This item is read only and cannot be modified. Read Only
ObservableSortedList.OrderChanged: self._maid:Add(Signal<T,Symbol>)

Fires when an item's order changes.

CountChanged

ObservableSortedList.CountChanged: RBXScriptSignal

Fires when the count changes.

Functions

new

ObservableSortedList.new(
isReversedboolean,
comparefunction
) → ObservableSortedList<T>

Constructs a new ObservableSortedList

isObservableSortedList

ObservableSortedList.isObservableSortedList(valueany) → boolean

Returns whether the value is an observable list

Observe

ObservableSortedList:Observe() → Observable<{T}>

Observes the list, allocating a new list in the process.

ObserveItemsBrio

ObservableSortedList:ObserveItemsBrio() → Observable<Brio<T,Symbol>>

Observes all items in the list

FindFirstKey

ObservableSortedList:FindFirstKey(contentT) → Symbol

Gets the first key for a given symbol

ObserveIndex

ObservableSortedList:ObserveIndex(indexToObservenumber) → Observable<number>

Observes the index as it changes, until the entry at the existing index is removed.

ObserveAtIndex

ObservableSortedList:ObserveAtIndex(indexToObservenumber) → Observable<T>

Observes the current value at a given index. This can be useful for observing the first entry, or matching stuff up to a given slot.

ObserveIndexByKey

ObservableSortedList:ObserveIndexByKey(keySymbol) → Observable<number>

Observes the index as it changes, until the entry at the existing key is removed.

GetIndexByKey

ObservableSortedList:GetIndexByKey(keySymbol) → number

Gets the current index from the key

GetCount

ObservableSortedList:GetCount() → number

Gets the count of items in the list

GetList

ObservableSortedList:GetList() → {T}

Gets a list of all entries.

ObserveCount

ObservableSortedList:ObserveCount() → Observable<number>

Observes the count of the list

Add

ObservableSortedList:Add(
itemT,
observeValueObservable<Comparable>
) → callback--

Call to remove

Adds the item to the list at the specified index

Get

ObservableSortedList:Get(indexnumber) → T?

Gets the current item at the index, or nil if it is not defined.

RemoveByKey

ObservableSortedList:RemoveByKey(keySymbol) → T

Removes the item from the list if it exists.

Destroy

ObservableSortedList:Destroy() → ()

Cleans up the ObservableSortedList and sets the metatable to nil.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": "Constructs a new ObservableSortedList",
            "params": [
                {
                    "name": "isReversed",
                    "desc": "",
                    "lua_type": "boolean"
                },
                {
                    "name": "compare",
                    "desc": "",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ObservableSortedList<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 52,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "Observe",
            "desc": "Observes the list, allocating a new list in the process.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<{ T }>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 117,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "isObservableSortedList",
            "desc": "Returns whether the value is an observable list",
            "params": [
                {
                    "name": "value",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "boolean"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 136,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ObserveItemsBrio",
            "desc": "Observes all items in the list",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<T, Symbol>>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 144,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "FindFirstKey",
            "desc": "Gets the first key for a given symbol",
            "params": [
                {
                    "name": "content",
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Symbol"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 179,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ObserveIndex",
            "desc": "Observes the index as it changes, until the entry at the existing\nindex is removed.",
            "params": [
                {
                    "name": "indexToObserve",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 196,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ObserveAtIndex",
            "desc": "Observes the current value at a given index. This can be useful for observing\nthe first entry, or matching stuff up to a given slot.",
            "params": [
                {
                    "name": "indexToObserve",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 214,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ObserveIndexByKey",
            "desc": "Observes the index as it changes, until the entry at the existing\nkey is removed.",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "Symbol"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 232,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "GetIndexByKey",
            "desc": "Gets the current index from the key",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "Symbol"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 270,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "GetCount",
            "desc": "Gets the count of items in the list",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 283,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "GetList",
            "desc": "Gets a list of all entries.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ T }"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 291,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ObserveCount",
            "desc": "Observes the count of the list",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 303,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "Add",
            "desc": "Adds the item to the list at the specified index",
            "params": [
                {
                    "name": "item",
                    "desc": "",
                    "lua_type": "T"
                },
                {
                    "name": "observeValue",
                    "desc": "",
                    "lua_type": "Observable<Comparable>"
                }
            ],
            "returns": [
                {
                    "desc": "Call to remove",
                    "lua_type": "callback"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 313,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "Get",
            "desc": "Gets the current item at the index, or nil if it is not defined.",
            "params": [
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 373,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "RemoveByKey",
            "desc": "Removes the item from the list if it exists.",
            "params": [
                {
                    "name": "key",
                    "desc": "",
                    "lua_type": "Symbol"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 389,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "Destroy",
            "desc": "Cleans up the ObservableSortedList and sets the metatable to nil.",
            "params": [],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 737,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        }
    ],
    "properties": [
        {
            "name": "ItemAdded",
            "desc": "Fires when an item is added",
            "lua_type": "Signal<T, number, Symbol>",
            "readonly": true,
            "source": {
                "line": 84,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ItemRemoved",
            "desc": "Fires when an item is removed.",
            "lua_type": "self._maid:Add(Signal<T, Symbol>)",
            "readonly": true,
            "source": {
                "line": 92,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "OrderChanged",
            "desc": "Fires when an item's order changes.",
            "lua_type": "self._maid:Add(Signal<T, Symbol>)",
            "readonly": true,
            "source": {
                "line": 100,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "CountChanged",
            "desc": "Fires when the count changes.",
            "lua_type": "RBXScriptSignal",
            "source": {
                "line": 107,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        }
    ],
    "types": [],
    "name": "ObservableSortedList",
    "desc": "A list that can be observed for blend and other components and maintains sorting order.\n\nThis class is very expensive to use as it enforces maintaining order on the object. Each entries produces\nwhat is most likely 4-5 tables, and changing can result in O(n) table construction and deltas.\n\nHowever, for small lists that don't change frequently, such as a global leaderboard, this can be\na nice small interactive class.\n\nFor performance reasons this class defers firing events until the next defer() event frame.\n\nThis class always prefers to add equivalent elements to the end of the list if they're not in the list.\nOtherwise it prefers minimal movement.",
    "source": {
        "line": 17,
        "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
    }
}