Skip to main content

BaseComponent

A Component Extension which applies simple Janitor, Attribute, and Signal functionality to a component. Also adds a way to check if a Component has been destroyed.

Extends ComponentJanitorUtil and ComponentAttributeUtil. Check their documentation for more information.

Functions

GetAttribute

BaseComponent:GetAttribute(
attributeNamestring--

The name of the attribute to fetch

) → any?--

The current value of the attribute

Fetches the current Value of an attribute on the Component Instance

SetAttribute

BaseComponent:SetAttribute(
attributeNamestring,--

The name of the attribute to set

valueany--

The value to set the attribute to

) → ()

Sets an attribute of this Component's instance to a value

IncrementAttribute

BaseComponent:IncrementAttribute(
attributeNamestring,--

The name of the attribute to increment

incrementnumber?--

The amount to increment the attribute by. Defaults to 1

) → number--

The new value of the attribute

Increments the current value of the attribute by the increment. If no increment is provided, it defaults to 1

UpdateAttribute

BaseComponent:UpdateAttribute(
attributeNamestring,--

The name of the attribute to mutate

mutator((valueany) → (any))--

The function to mutate the attribute with

) → any--

The new value of the attribute

Updates the current value of the attribute into a new value from the return of the mutator function

ObserveAttribute

BaseComponent:ObserveAttribute(
attributeNamestring,--

The name of the attribute to observe

callback((newValueany) → ())--

The function to call when the attribute changes

) → function--

A function to disconnect the observer

Watches for when the attribute changes and calls the callback. Also calls the callback initially with the current value

OutAttribute

BaseComponent:OutAttribute(
attributeNamestring--

The name of the attribute to fetch

) → Value<any>--

The synchronized fusion value of the attribute

Fetches an attribute and turns into into a synchronized usable value

DefaultAttribute

BaseComponent:DefaultAttribute(
attributeNamestring,--

The name of the attribute to set

valueany,--

The value to set the attribute to

validDataTypes{string}?--

A list of valid data types for the attribute

) → any--

The value of the attribute

Sets an attribute to a default value if it is not already set, allows for type checking of the initial value

AttributeChanged

BaseComponent:AttributeChanged(
attributeNamestring,--

The name of the attribute to observe

fn((...any) → ())?--

The function to call when the attribute changes

) → RBXScriptConnection | RBXScriptSignal--

A function to disconnect the observer or the signal

Fetches the AttributeChanged signal for the attribute if no function is given. If a function is provided, it will connect the function to the attribute changed signal and return the connection

GetScope

BaseComponent:GetScope() → Scope<any>

Returns a scope associated with the lifecycle of the component. Inherits methods from RailUtil.Fusion and Fusion.

AddPromise

BaseComponent:AddPromise(promisePromise<T>) → Promise<T>

Adds a promise to the component's janitor. Returns the same promise that was given.

AddTask

BaseComponent:AddTask(
taskT,
cleanupMethod(string | true)?,
indexany?
) → T--

The same task that was given

Adds a task to the component's janitor.

RemoveTaskNoClean

BaseComponent:RemoveTaskNoClean(
indexany--

The index of the task to remove.

) → ()

Removes a task from the component's janitor without cleaning it.

RemoveTask

BaseComponent:RemoveTask(
indexany,--

The id of the task to remove.

dontCleanboolean?--

Optional flag to not clean the task.

) → ()

Removes a task from the component's janitor.

GetTask

BaseComponent:GetTask(
indexany--

The id of the task to get.

) → any--

The task that was retrieved.

Gets a task from the janitor.

ObserveProperty

BaseComponent:ObserveProperty(
propertyNamestring,--

The name of the property to observe

callback((newValueany) → ())--

The function to call when the property changes

) → function--

A function to disconnect the observer

Watches for when the property changes and calls the callback. Also calls the callback initially with the current value

OutProperty

BaseComponent:OutProperty(
propertyNamestring--

The name of the property to fetch

) → Value<any>--

The synchronized fusion value of the property

Fetches an property and turns into into a synchronized usable value

PropertyChanged

BaseComponent:PropertyChanged(
propertyNamestring,--

The name of the property to observe

fn((...any) → ())?,--

The function to call when the property changes

connectOnceboolean?--

If true, the function will only be called the first time the property changes

) → RBXScriptConnection | RBXScriptSignal--

A connection or signal

Fetches the PropertyChanged signal for the property if no function is given. If a function is provided, it will connect the function to the property changed signal and return the connection

RegisterSignal

BaseComponent:RegisterSignal(
signalNamestring--

The name of the signal to register.

) → Signal--

The signal that was registered.

Registers a signal to the component.

GetSignal

BaseComponent:GetSignal(
signalNamestring--

The name of the signal to get.

) → Signal--

The signal that was retrieved.

Gets a signal from the component.

FireSignal

BaseComponent:FireSignal(
signalNamestring,--

The name of the signal to fire.

...any--

The arguments to pass to the signal.

) → ()

Fires a signal from the component.

Show raw api
{
    "functions": [
        {
            "name": "GetAttribute",
            "desc": "Fetches the current Value of an attribute on the Component Instance",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to fetch",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The current value of the attribute",
                    "lua_type": "any?"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 61,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "SetAttribute",
            "desc": "Sets an attribute of this Component's instance to a value",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to set",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "The value to set the attribute to",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 75,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "IncrementAttribute",
            "desc": "Increments the current value of the attribute by the increment. If no increment is provided, it defaults to 1",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to increment",
                    "lua_type": "string"
                },
                {
                    "name": "increment",
                    "desc": "The amount to increment the attribute by. Defaults to 1",
                    "lua_type": "number?"
                }
            ],
            "returns": [
                {
                    "desc": "The new value of the attribute",
                    "lua_type": "number"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 89,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "UpdateAttribute",
            "desc": "Updates the current value of the attribute into a new value from the return of the mutator function",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to mutate",
                    "lua_type": "string"
                },
                {
                    "name": "mutator",
                    "desc": "The function to mutate the attribute with",
                    "lua_type": "((value: any) -> (any))"
                }
            ],
            "returns": [
                {
                    "desc": "The new value of the attribute",
                    "lua_type": "any"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 107,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "ObserveAttribute",
            "desc": "Watches for when the attribute changes and calls the callback. Also calls the callback initially with the current value",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to observe",
                    "lua_type": "string"
                },
                {
                    "name": "callback",
                    "desc": "The function to call when the attribute changes",
                    "lua_type": "((newValue: any) -> ())"
                }
            ],
            "returns": [
                {
                    "desc": "A function to disconnect the observer",
                    "lua_type": "function"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 124,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "OutAttribute",
            "desc": "Fetches an attribute and turns into into a synchronized usable value",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to fetch",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The synchronized fusion value of the attribute",
                    "lua_type": "Value<any>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 151,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "DefaultAttribute",
            "desc": "Sets an attribute to a default value if it is not already set, allows for type checking of the initial value",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to set",
                    "lua_type": "string"
                },
                {
                    "name": "value",
                    "desc": "The value to set the attribute to",
                    "lua_type": "any"
                },
                {
                    "name": "validDataTypes",
                    "desc": "A list of valid data types for the attribute",
                    "lua_type": "{string}?"
                }
            ],
            "returns": [
                {
                    "desc": "The value of the attribute",
                    "lua_type": "any"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 181,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "AttributeChanged",
            "desc": "Fetches the AttributeChanged signal for the attribute if no function is given.\nIf a function is provided, it will connect the function to the attribute changed signal and return the connection",
            "params": [
                {
                    "name": "attributeName",
                    "desc": "The name of the attribute to observe",
                    "lua_type": "string"
                },
                {
                    "name": "fn",
                    "desc": "The function to call when the attribute changes",
                    "lua_type": "((...any) -> ())?"
                }
            ],
            "returns": [
                {
                    "desc": "A function to disconnect the observer or the signal",
                    "lua_type": "RBXScriptConnection | RBXScriptSignal"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 208,
                "path": "lib/basecomponent/src/ComponentAttributeUtil.luau"
            }
        },
        {
            "name": "GetScope",
            "desc": "Returns a scope associated with the lifecycle of the component.\nInherits methods from RailUtil.Fusion and Fusion.",
            "params": [],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Scope<any>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 46,
                "path": "lib/basecomponent/src/ComponentFusionUtil.luau"
            }
        },
        {
            "name": "AddPromise",
            "desc": "Adds a promise to the component's janitor. Returns the same promise that was given.",
            "params": [
                {
                    "name": "promise",
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "returns": [
                {
                    "desc": "",
                    "lua_type": "Promise<T>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 50,
                "path": "lib/basecomponent/src/ComponentJanitorUtil.luau"
            }
        },
        {
            "name": "AddTask",
            "desc": "Adds a task to the component's janitor.",
            "params": [
                {
                    "name": "task",
                    "desc": "",
                    "lua_type": "T"
                },
                {
                    "name": "cleanupMethod",
                    "desc": "",
                    "lua_type": "(string | true)?"
                },
                {
                    "name": "index",
                    "desc": "",
                    "lua_type": "any?"
                }
            ],
            "returns": [
                {
                    "desc": "The same task that was given",
                    "lua_type": "T"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 65,
                "path": "lib/basecomponent/src/ComponentJanitorUtil.luau"
            }
        },
        {
            "name": "RemoveTaskNoClean",
            "desc": "Removes a task from the component's janitor without cleaning it.",
            "params": [
                {
                    "name": "index",
                    "desc": "The index of the task to remove.",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 77,
                "path": "lib/basecomponent/src/ComponentJanitorUtil.luau"
            }
        },
        {
            "name": "RemoveTask",
            "desc": "Removes a task from the component's janitor.",
            "params": [
                {
                    "name": "index",
                    "desc": "The id of the task to remove.",
                    "lua_type": "any"
                },
                {
                    "name": "dontClean",
                    "desc": "Optional flag to not clean the task.",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 90,
                "path": "lib/basecomponent/src/ComponentJanitorUtil.luau"
            }
        },
        {
            "name": "GetTask",
            "desc": "Gets a task from the janitor.",
            "params": [
                {
                    "name": "index",
                    "desc": "The id of the task to get.",
                    "lua_type": "any"
                }
            ],
            "returns": [
                {
                    "desc": "The task that was retrieved.",
                    "lua_type": "any"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 106,
                "path": "lib/basecomponent/src/ComponentJanitorUtil.luau"
            }
        },
        {
            "name": "ObserveProperty",
            "desc": "Watches for when the property changes and calls the callback. Also calls the callback initially with the current value",
            "params": [
                {
                    "name": "propertyName",
                    "desc": "The name of the property to observe",
                    "lua_type": "string"
                },
                {
                    "name": "callback",
                    "desc": "The function to call when the property changes",
                    "lua_type": "((newValue: any) -> ())"
                }
            ],
            "returns": [
                {
                    "desc": "A function to disconnect the observer",
                    "lua_type": "function"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 53,
                "path": "lib/basecomponent/src/ComponentPropertyUtil.luau"
            }
        },
        {
            "name": "OutProperty",
            "desc": "Fetches an property and turns into into a synchronized usable value",
            "params": [
                {
                    "name": "propertyName",
                    "desc": "The name of the property to fetch",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The synchronized fusion value of the property",
                    "lua_type": "Value<any>"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 80,
                "path": "lib/basecomponent/src/ComponentPropertyUtil.luau"
            }
        },
        {
            "name": "PropertyChanged",
            "desc": "Fetches the PropertyChanged signal for the property if no function is given.\nIf a function is provided, it will connect the function to the property changed signal and return the connection",
            "params": [
                {
                    "name": "propertyName",
                    "desc": "The name of the property to observe",
                    "lua_type": "string"
                },
                {
                    "name": "fn",
                    "desc": "The function to call when the property changes",
                    "lua_type": "((...any) -> ())?"
                },
                {
                    "name": "connectOnce",
                    "desc": "If true, the function will only be called the first time the property changes",
                    "lua_type": "boolean?"
                }
            ],
            "returns": [
                {
                    "desc": "A connection or signal",
                    "lua_type": "RBXScriptConnection | RBXScriptSignal"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 110,
                "path": "lib/basecomponent/src/ComponentPropertyUtil.luau"
            }
        },
        {
            "name": "RegisterSignal",
            "desc": "Registers a signal to the component.",
            "params": [
                {
                    "name": "signalName",
                    "desc": "The name of the signal to register.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The signal that was registered.",
                    "lua_type": "Signal"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 66,
                "path": "lib/basecomponent/src/init.luau"
            }
        },
        {
            "name": "GetSignal",
            "desc": "Gets a signal from the component.",
            "params": [
                {
                    "name": "signalName",
                    "desc": "The name of the signal to get.",
                    "lua_type": "string"
                }
            ],
            "returns": [
                {
                    "desc": "The signal that was retrieved.",
                    "lua_type": "Signal"
                }
            ],
            "function_type": "method",
            "source": {
                "line": 85,
                "path": "lib/basecomponent/src/init.luau"
            }
        },
        {
            "name": "FireSignal",
            "desc": "Fires a signal from the component.",
            "params": [
                {
                    "name": "signalName",
                    "desc": "The name of the signal to fire.",
                    "lua_type": "string"
                },
                {
                    "name": "...",
                    "desc": "The arguments to pass to the signal.",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "method",
            "source": {
                "line": 104,
                "path": "lib/basecomponent/src/init.luau"
            }
        },
        {
            "name": "Constructing",
            "desc": "",
            "params": [
                {
                    "name": "component",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "static",
            "ignore": true,
            "source": {
                "line": 144,
                "path": "lib/basecomponent/src/init.luau"
            }
        },
        {
            "name": "Stopped",
            "desc": "",
            "params": [
                {
                    "name": "component",
                    "desc": "",
                    "lua_type": "any"
                }
            ],
            "returns": [],
            "function_type": "static",
            "ignore": true,
            "source": {
                "line": 160,
                "path": "lib/basecomponent/src/init.luau"
            }
        }
    ],
    "properties": [],
    "types": [],
    "name": "BaseComponent",
    "desc": "A Component Extension which applies simple Janitor, Attribute, and Signal functionality to a component.\nAlso adds a way to check if a Component has been destroyed.\n\nExtends **ComponentJanitorUtil** and **ComponentAttributeUtil**.\nCheck their documentation for more information.",
    "source": {
        "line": 14,
        "path": "lib/basecomponent/src/init.luau"
    }
}