Skip to main content

GlobalUpdates

This item only works when running on the server. Server

Used to add, lock and change global updates.

Revealed through :PostGlobalUpdate().

Types

GlobalUpdateData

type GlobalUpdateData = {[any]any}

GlobalUpdates

type GlobalUpdates = {
Idnumber,
Updates{GlobalUpdate}
}

Id is the most recent update index.

Functions

AddGlobalUpdate

GlobalUpdates:AddGlobalUpdate(globalUpdateData{[any]any}) → Promise<number>

Adds a global update to the Keep.

store:PostGlobalUpdate(function(globalUpdates)
	globalUpdates:AddGlobalUpdate({
		Hello = "World!",
	}):andThen(function(updateId)
		print("Added Global Update!", updateId)
	end)
end)

ChangeActiveUpdate

GlobalUpdates:ChangeActiveUpdate(
updateIdnumber,
globalUpdateData{[any]any}
) → Promise<()>

Change an active global update's data to the new data.

Useful for stacking updates to save space for Keeps that maybe receiving lots of globals. Ex. a content creator receiving gifts.

RemoveActiveUpdate

GlobalUpdates:RemoveActiveUpdate(updateIdnumber) → Promise<()>

Removes an active global update.

local updates = globalUpdates:GetActiveUpdates()

for _, update in updates do
	globalUpdates:RemoveActiveUpdate(update.Id):andThen(function()
		print("Removed Global Update!")
	end)
end

GetActiveUpdates

GlobalUpdates:GetActiveUpdates() → {GlobalUpdate}

Types

type GlobalUpdate = {
Idnumber,
Lockedboolean,
}

Returns all active global updates.

local updates = globalUpdates:GetActiveUpdates()

for _, update in updates do
	print("ActiveUpdate data:", update.Data)
end
Show raw api
{
    "functions": [
        {
            "name": "AddGlobalUpdate",
            "desc": "Adds a global update to the Keep.\n\n```lua\nstore:PostGlobalUpdate(function(globalUpdates)\n\tglobalUpdates:AddGlobalUpdate({\n\t\tHello = \"World!\",\n\t}):andThen(function(updateId)\n\t\tprint(\"Added Global Update!\", updateId)\n\tend)\nend)\n```",
            "params": [
                {
                    "name": "globalUpdateData",
                    "desc": "",
                    "lua_type": "{ [any]: any }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<number>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 46,
                "path": "src/GlobalUpdates.luau"
            }
        },
        {
            "name": "ChangeActiveUpdate",
            "desc": "Change an **active** global update's data to the new data.\n\nUseful for stacking updates to save space for Keeps that maybe receiving lots of globals. Ex. a content creator receiving gifts.",
            "params": [
                {
                    "name": "updateId",
                    "desc": "",
                    "lua_type": "number"
                },
                {
                    "name": "globalUpdateData",
                    "desc": "",
                    "lua_type": "{ [any]: any }"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<()>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 79,
                "path": "src/GlobalUpdates.luau"
            }
        },
        {
            "name": "RemoveActiveUpdate",
            "desc": "Removes an active global update.\n\n```lua\nlocal updates = globalUpdates:GetActiveUpdates()\n\nfor _, update in updates do\n\tglobalUpdates:RemoveActiveUpdate(update.Id):andThen(function()\n\t\tprint(\"Removed Global Update!\")\n\tend)\nend\n```",
            "params": [
                {
                    "name": "updateId",
                    "desc": "",
                    "lua_type": "number"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<()>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 124,
                "path": "src/GlobalUpdates.luau"
            }
        },
        {
            "name": "GetActiveUpdates",
            "desc": "Returns all **active** global updates.\n\n```lua\nlocal updates = globalUpdates:GetActiveUpdates()\n\nfor _, update in updates do\n\tprint(\"ActiveUpdate data:\", update.Data)\nend\n```",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "{ GlobalUpdate }"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 176,
                "path": "src/GlobalUpdates.luau"
            }
        }
    ],
    "properties": [],
    "types": [
        {
            "name": "GlobalUpdateData",
            "desc": "",
            "lua_type": "{ [any]: any }",
            "source": {
                "line": 255,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "GlobalUpdate",
            "desc": "",
            "lua_type": "{ Id: number, Locked: boolean, Data: GlobalUpdateData }",
            "source": {
                "line": 262,
                "path": "src/Types.luau"
            }
        },
        {
            "name": "GlobalUpdates",
            "desc": "```Id``` is the most recent update index.",
            "lua_type": "{ Id: number, Updates: { GlobalUpdate } }",
            "source": {
                "line": 275,
                "path": "src/Types.luau"
            }
        }
    ],
    "name": "GlobalUpdates",
    "desc": "Used to add, lock and change global updates.\n\nRevealed through [:PostGlobalUpdate()](Store#PostGlobalUpdate).",
    "realm": [
        "Server"
    ],
    "source": {
        "line": 23,
        "path": "src/GlobalUpdates.luau"
    }
}