Start typing to search packages!
loader
By @cosinewaves
Roblox
Mirrored from WallyThis version ships no README. Showing the README from v1.2.1, mirrored from wally.
⚙️ Loader
A lightweight, lifecycle-aware module loader for Roblox. This utility ensures a consistent init → start boot process across your game’s services and modules. Designed for modular architecture, dependency safety, and async initialization.
⚠️ This is a Promise-based module loader. You should be familiar with Promise usage in Roblox to use it effectively.
🚀 Key Features
- 🔁 Consistent Lifecycle: Each module can optionally export
init()andstart()for structured loading. - ⏳ Async Safety: Modules are
requiredsafely, andstart()is deferred untilinit()of all modules is complete. - 🧩 Dependency Coordination: Use
waitFor("ModuleName")to safely depend on another module’s completion. - 📦 Batch Loading: Load all children or descendant
ModuleScriptsfrom a container.
📦 Installation
Drop the module into your project and require() it once during bootstrap.
local Loader = require(path.to.loader)
⸻
📜 Module Lifecycle Order
Each module can export the following optional functions and you can include your own:
init(): () -> ()
-- Called immediately after require().
-- Use it to set up values, caches, or internal state.
-- All init() methods are called before any start().
start(): () -> ()
-- Called after all modules’ init() have run.
-- Use this to begin logic, connect systems, or run loops.
-- Automatically runs asynchronously.
waitFor(name: string): Promise<any>
-- Provided automatically in each module’s returned table.
-- Lets you await other modules’ startup before proceeding.
⸻
🧩 Public API
loader.load_children(container: Instance, predicate?: (Instance) -> boolean): Promise<boolean>
-- Loads all ModuleScripts that are direct children of the container.
-- If a predicate is provided, only ModuleScripts where predicate(module) == true will be loaded.
-- ✅ Optional predicate to filter modules.
-- ✅ Returns a Promise that resolves after all modules are started.
Loader:load_children(game.ReplicatedStorage.Modules)
⸻
loader.load_descendants(container: Instance, predicate?: (Instance) -> boolean): Promise<boolean>
-- Loads all ModuleScripts found recursively in the container’s descendants.
-- If a predicate is provided, only ModuleScripts where predicate(module) == true will be loaded.
Loader:load_descendants(game.ServerScriptService.Services)
⸻
🔍 Predicate Examples
Here are some example predicates you can pass into load_children or load_descendants to control which modules are loaded:
-- Load only modules whose name ends with "Service"
local function endsWithService(module)
return module.Name:match("Service$") ~= nil
end
Loader:load_descendants(script.Modules, endsWithService)
-- Load only modules that have a specific tag
local CollectionService = game:GetService("CollectionService")
local function isTagged(module)
return CollectionService:HasTag(module, "LoadMe")
end
Loader:load_descendants(script.Modules, isTagged)
-- Load only modules in a specific namespace
local function isCoreModule(module)
return module.Name:sub(1, 5) == "Core_"
end
Loader:load_children(script.Modules, isCoreModule)
Package Details
Install command (Click to copy)
Version
1.2.4
License
MIT
Safe for commercial use
The package archive does not include its license text; the license is declared in its manifest metadata.
Automated license review — not legal advice.
