Skip to main content

queryUtil

A utility for basic query operations.

Types

Connection

type Connection = RBXScriptConnection | {
Connectedboolean,
Disconnect(selfConnection) → ()
}

EventLike<T>

type EventLike<T> = {
Connect((T) → ()) → Connection,
connect((T) → ()) → Connection
}

Functions

query

queryUtil.query(
queryResultsT,
queryAdditionEventLike<T>,
queryRemovingEventLike<T>
) → Property<T>,Trove

Returns a property object and a trove. The property object is initially updated with queryResults, and then updated based off of queryAddition and queryRemoving events firing off.

local Workspace = game:GetService("Workspace")

local queryResultsProperty, cleanup = queryUtil.query(
	Workspace:GetDescendants(), 
	Workspace.DescendantAdded, 
	Workspace.DescendantRemoving
)

queryResultsProperty:observe(function(newQueryResults, oldQueryResults)
	print(newQueryResults) --> {...} (Array of all Workspace descendants)
end)
Show raw api
{
    "functions": [
        {
            "name": "query",
            "desc": " \nReturns a property object and a trove. The property object is initially updated with \n`queryResults`, and then updated based off of `queryAddition` and `queryRemoving` events\nfiring off.\n\n```lua\nlocal Workspace = game:GetService(\"Workspace\")\n\nlocal queryResultsProperty, cleanup = queryUtil.query(\n\tWorkspace:GetDescendants(), \n\tWorkspace.DescendantAdded, \n\tWorkspace.DescendantRemoving\n)\n\nqueryResultsProperty:observe(function(newQueryResults, oldQueryResults)\n\tprint(newQueryResults) --> {...} (Array of all Workspace descendants)\nend)\n```",
            "params": [
                {
                    "name": "queryResults",
                    "desc": "",
                    "lua_type": "T"
                },
                {
                    "name": "queryAddition",
                    "desc": "",
                    "lua_type": "EventLike<T>"
                },
                {
                    "name": "queryRemoving",
                    "desc": "",
                    "lua_type": "EventLike<T>\n"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Property<T>, Trove"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 72,
                "path": "src/queryUtil/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "Connection",
            "desc": " ",
            "lua_type": "RBXScriptConnection | {Connected: boolean, Disconnect: (self: Connection) -> ()}",
            "source": {
                "line": 11,
                "path": "src/queryUtil/init.luau"
            }
        },
        {
            "name": "EventLike<T>",
            "desc": " ",
            "lua_type": "{Connect: ((T) -> ()) -> Connection, connect: ((T) -> ()) -> Connection}",
            "source": {
                "line": 16,
                "path": "src/queryUtil/init.luau"
            }
        }
    ],
    "name": "queryUtil",
    "desc": " \n\nA utility for basic query operations.",
    "source": {
        "line": 6,
        "path": "src/queryUtil/init.luau"
    }
}