Forest Logo
search
package_2

lambda

By @cosinewaves

Roblox

Mirrored

[image: Lambda logo stolen from half-life 2 - sorry not sorry]

λ Lambda

A lightweight lifecycle orchestrator for ModuleScripts. Lambda ensures a consistent init → start boot process across a list of modules, with full Promise support for async initialisation.

[!IMPORTANT] This module depends on a working lua Promise implementation (such as evaera/roblox-lua-promise ) - make sure you’ve required it correctly inside the library


🚀 Key Features

  • 🔁 Consistent Lifecycle: Each module can optionally export init() and start() for structured loading.
  • Async Safety: Modules are required safely, and start() is deferred until init() of all modules is complete.
  • 📦 Batch Loading: Load all children or descendant ModuleScripts from a container.

📦 Installation

Place lambda/init.lua in your project, then call it once with your target ModuleScripts:

local Lambda = require(path.to.lambda)

local modules: {ModuleScript} = {
    script.Services.PlayerService,
    script.Services.InventoryService,
    script.Services.MatchService,
}

Lambda(modules)

📜 Module Lifecycle

Each module you load can optionally export:

init(): () | Promise

  • Called immediately after require().
  • All init() methods are awaited before any start().

start(): () | Promise

  • Called after every module’s init() has resolved.

[!TIP] Both lifecycle functions are optional, you can mix and match.

Example Module:

local PlayerService = {}

function PlayerService.init(): ()
    print("PlayerService initializing...")
    return Promise.delay(1):andThen(function()
        print("PlayerService init complete")
    end)
end

function PlayerService.start(): ()
    print("PlayerService starting...")
end

return PlayerService

🔍 Usage Notes

  • If a module throws during require, Lambda rejects immediately.
  • If init() or start() throws, it’s caught and wrapped in a rejected Promise.
  • Non-Promise return values are automatically wrapped in Promise.resolve().

Package Details

Install command (Click to copy)


Version

0.1.4

License

MIT

check_circle

Safe for commercial use

infoThe package archive does not include its license text; the license is declared in its manifest metadata.

Automated license review — not legal advice.