Skip to main content

Lifecycle

A lifecycle is a class that allows you to call a certain function on every service. For example, you could have an "onStart" lifecycle.

Functions

new

Lifecycle.new(
namestring,
dispatcherBaseDispatcher
) → ()

Create a new Lifecycle with the given name. You can optionally pass a dispatcher to use, it defaults to an AsyncDispatcher if nothing is passed.

fire

Lifecycle:fire(...any) → ()

Fires the lifecycle, anything passed into ... will also be passed to every function which this lifecycle invokes.

Show raw api
{
    "functions": [
        {
            "name": "new",
            "desc": " \nCreate a new Lifecycle with the given `name`. You can optionally pass a dispatcher to use,\nit defaults to an AsyncDispatcher if nothing is passed.",
            "params": [
                {
                    "name": "name",
                    "desc": "",
                    "lua_type": "string"
                },
                {
                    "name": "dispatcher",
                    "desc": "",
                    "lua_type": "BaseDispatcher"
                }
            ],
            "returns": [],
            "function_type": "static",
            "source": {
                "line": 29,
                "path": "packages/sapling/source/classes/Lifecycle.luau"
            }
        },
        {
            "name": "fire",
            "desc": "Fires the lifecycle, anything passed into `...` will also be passed to every function which this\nlifecycle invokes.",
            "params": [
                {
                    "name": "...",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 63,
                "path": "packages/sapling/source/classes/Lifecycle.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "Lifecycle",
    "desc": "A lifecycle is a class that allows you to call a certain function on every service. For example,\nyou could have an \"onStart\" lifecycle.",
    "source": {
        "line": 12,
        "path": "packages/sapling/source/classes/Lifecycle.luau"
    }
}