Skip to main content

BindToCloseService

Allows unregisterable BindToClose callbacks. This is important because you can't unbind :BindToClose calls normally, so we need to provide another place to guarantee clean shutdowns.

Functions​

PromiseClose​

BindToCloseService.PromiseClose(self: BindToCloseService) → Promise

Closes the game: runs every registered close callback, as Roblox does when the server shuts down, and resolves once they have all resolved. Destroying a ServiceBag does not close the game, so call this before tearing down a server bag while the game keeps running, such as in tests.

The game closes once. Later calls, including Roblox's own shutdown, return the same promise.

RegisterPromiseOnCloseCallback​

BindToCloseService.RegisterPromiseOnCloseCallback(
saveCallback: function
) → function--

Call to unregister callback

Binds the promise to call on close. Can be unregistered

Show raw api
{
    "functions": [
        {
            "name": "PromiseClose",
            "desc": "Closes the game: runs every registered close callback, as Roblox does when the server shuts down,\nand resolves once they have all resolved. Destroying a [ServiceBag] does not close the game, so\ncall this before tearing down a server bag while the game keeps running, such as in tests.\n\nThe game closes once. Later calls, including Roblox's own shutdown, return the same promise.",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "BindToCloseService"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 68,
                "path": "src/bindtocloseservice/src/Server/BindToCloseService.lua"
            }
        },
        {
            "name": "RegisterPromiseOnCloseCallback",
            "desc": "Binds the promise to call on close. Can be unregistered",
            "params": [
                {
                    "name": "self",
                    "desc": "",
                    "lua_type": "BindToCloseService"
                },
                {
                    "name": "saveCallback",
                    "desc": "",
                    "lua_type": "function"
                }
            ],
            "returns": [
                {
                    "desc": "Call to unregister callback",
                    "lua_type": "function"
                }
            ],
            "function_type": "static",
            "source": {
                "line": 99,
                "path": "src/bindtocloseservice/src/Server/BindToCloseService.lua"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "BindToCloseService",
    "desc": "Allows unregisterable BindToClose callbacks. This is important because you can't unbind\n:BindToClose calls normally, so we need to provide another place to guarantee clean shutdowns.",
    "source": {
        "line": 8,
        "path": "src/bindtocloseservice/src/Server/BindToCloseService.lua"
    }
}