Skip to content

Update init.luau to add "ConnectFunctions" method#235

Open
0929lego wants to merge 1 commit intoSleitnick:mainfrom
0929lego:main
Open

Update init.luau to add "ConnectFunctions" method#235
0929lego wants to merge 1 commit intoSleitnick:mainfrom
0929lego:main

Conversation

@0929lego
Copy link

The Loader module is great for making quick frameworks. However, I find it useful in my own projects to have some additional code that looks for common methods like Players.PlayerAdded and connects them in the initialization process rather than connecting multiple events in each module.

This update adds the necessary code to the Loader utility module to make it easy to do the above. For example:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")

local Loader = require(ReplicatedStorage.Loader)
local LoadedModules = Loader.LoadDescendants(ReplicatedStorage, Loader.MatchesName("Service$"))

Loader.SpawnAll(LoadedModules, "OnStart")
Loader.ConnectFunctions(LoadedModules, Players.PlayerAdded, "OnPlayerAdded")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant