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, ComponentAttributeUtil, and ComponentPropertyUtil. Check their documentation for more information.
Functions
ObserveProperty
BaseComponent:ObserveProperty(propertyName: string,--
The name of the property to observe
callback: ((newValue: any) → ())--
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(propertyName: string--
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(propertyName: string,--
The name of the property to observe
fn: ((...any) → ())?,--
The function to call when the property changes
connectOnce: boolean?--
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(signalName: string--
The name of the signal to register.
) → Signal--
The signal that was registered.
Registers a signal to the component.
GetSignal
BaseComponent:GetSignal(signalName: string--
The name of the signal to get.
) → Signal--
The signal that was retrieved.
Gets a signal from the component.
FireSignal
BaseComponent:FireSignal(signalName: string,--
The name of the signal to fire.
...: any--
The arguments to pass to the signal.
) → ()Fires a signal from the component.
ConnectSignal
BaseComponent:ConnectSignal(signalName: string,--
The name of the signal to connect to.
callback: (...any) → ()--
The callback to call when the signal is fired.
) → RBXScriptConnection--
The connection object.
Connects a callback to a signal.
AddPromise
BaseComponent:AddPromise(promise: Promise<T>) → Promise<T>Adds a promise to the component's janitor. Returns the same promise that was given.
AddTask
BaseComponent:AddTask(task: T,cleanupMethod: (string | true)?,index: any?) → T--
The same task that was given
Adds a task to the component's janitor.
RemoveTaskNoClean
BaseComponent:RemoveTaskNoClean(index: any--
The index of the task to remove.
) → ()Removes a task from the component's janitor without cleaning it.
RemoveTask
BaseComponent:RemoveTask(index: any,--
The id of the task to remove.
dontClean: boolean?--
Optional flag to not clean the task.
) → ()Removes a task from the component's janitor.
GetTask
BaseComponent:GetTask(index: any--
The id of the task to get.
) → any--
The task that was retrieved.
Gets a task from the janitor.
GetAttribute
BaseComponent:GetAttribute(attributeName: string--
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(attributeName: string,--
The name of the attribute to set
value: any--
The value to set the attribute to
) → ()Sets an attribute of this Component's instance to a value
IncrementAttribute
BaseComponent:IncrementAttribute(attributeName: string,--
The name of the attribute to increment
increment: number?--
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(attributeName: string,--
The name of the attribute to mutate
mutator: ((value: any) → (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(attributeName: string,--
The name of the attribute to observe
callback: ((newValue: any) → ())--
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(attributeName: string--
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(attributeName: string,--
The name of the attribute to set
value: any,--
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(attributeName: string,--
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.