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.

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: Signal<T,Symbol>

Fires when an item is removed.

CountChanged

ObservableSortedList.CountChanged: RBXScriptSignal

Fires when the count changes.

Functions

new

ObservableSortedList.new(comparecallback?) → ObservableSortedList<T>

Constructs a new ObservableSortedList

isObservableSortedList

ObservableSortedList.isObservableSortedList(valueany) → boolean

Returns whether the value is an observable list

ObserveItemsBrio

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

Observes all items in the list

ObserveIndex

ObservableSortedList:ObserveIndex(indexToObservenumber) → Observable<number>

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

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": "compare",
                    "desc": "",
                    "lua_type": "callback?"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "ObservableSortedList<T>"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 38,
                "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": 89,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ObserveItemsBrio",
            "desc": "Observes all items in the list",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Observable<Brio<T>>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 97,
                "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": 133,
                "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": 151,
                "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": 189,
                "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": 202,
                "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": 210,
                "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": 222,
                "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": 232,
                "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": 288,
                "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": 304,
                "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": 522,
                "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": 62,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "ItemRemoved",
            "desc": "Fires when an item is removed.",
            "lua_type": "Signal<T, Symbol>",
            "readonly": true,
            "source": {
                "line": 71,
                "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
            }
        },
        {
            "name": "CountChanged",
            "desc": "Fires when the count changes.",
            "lua_type": "RBXScriptSignal",
            "source": {
                "line": 79,
                "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.",
    "source": {
        "line": 14,
        "path": "src/observablecollection/src/Shared/ObservableSortedList.lua"
    }
}