Sapling
The main / core package of the Sapling framework.
Properties
Dispatchers
This item is read only and cannot be modified. Read OnlySapling.Dispatchers: anyAll the built-in dispatchers lifecycle dispatchers.
Functions
loadServices
Loads all module scripts under parent ignoring anything which isn't a ModuleScript instance.
loadPackages
This function only needs to be called if you are using any other Sapling Framework packages, simply point it to your Packages folder and Sapling will handle the rest.
If you do not call this function at the right time, or at all, pacakges will throw an error and tell you that you have not called this function.
WARNING
This function NEEDS to be called before you call loadServices otherwise packages will error.
Errors
| Type | Description |
|---|---|
| "You can only call loadPackages one time" | You should only call this function once, before you call `loadService`. |
fireLifecycle
Sapling.fireLifecycle(name: string,...: any) → ()Utility function to quickly fire a lifecycle, this is so you dont need to create a lifecycle object to fire it and whatever. You can just call this function with the name and any paramaters you want to pass.
createLifecycle
Just calls Lifecycle.new
extendBaseDispatcher
Sapling.extendBaseDispatcher() → ()This function returns a new class that extends the BaseDispatcher. Here is a basic example of a blocking dispatcher:
local BlockingDispatcher = Sapling.extendBaseDispatcher()
function BlockingDispatcher.dispatch(
self: typeof(BlockingDispatcher),
name: string,
...: any
)
-- The :collectFunctions() is a method on the baseDispatcher class, you can override it yourself
-- if you really want but there is simply no point to.
local functions = self:collectFunctions(name)
-- Loop through all the functiosn and call them
for _, fn in functions do
fn(...)
end
end
return BlockingDispatcher