{"id":"gigahd/onboot","name":"onboot","scope":"gigahd","platform":"roblox","description":"A simple Module to load your modules and services","version":"0.7.0","latest":"0.7.0","versions":["0.1.0","0.2.0","0.3.0","0.4.0","0.5.0","0.5.1","0.5.2","0.6.0","0.6.1","0.6.2","0.6.3","0.7.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"639dee1c6585edd6b5e5dc2ff1e564cc0ec811818fa8618e86c41cc3b03fdd00","likes":0,"downloads":0,"install":"forest install gigahd/onboot","url":"https://forest.dev/p/roblox/gigahd/onboot","files":"https://api.forest.dev/ai/package/roblox/gigahd/onboot/files","readme":"# onboot\nA simple way to initiate any module or service you need.\n\n## Installation\nAdd it to your `wally.toml`:\n\n```toml\n[dependencies]\nOnBoot = \"gigahd/onboot@0.7.0\"\n```\n\n## Quick start\n\n```luau\nlocal OnBoot = require(ReplicatedStorage.Packages.OnBoot)\n\nlocal services = OnBoot.LoadDescendants(ServerScriptService.Services, OnBoot.FindName(\"Service\"))\n\nOnBoot.SpawnPhasesAsync(services, { \"Init\", \"Start\" })\nprint(\"Everything is running\")\n```\n\nA service is any ModuleScript that returns a table with methods named after your phases:\n\n```luau\nlocal DataService = {}\nDataService.Priority = 10\n\nfunction DataService:Init() end\nfunction DataService:Start() end\n\nreturn DataService\n```\n\n### [Documentation](https://gigahd.github.io/onboot/)\n\n## Loading\n\nEvery loader returns a `LoadedModules` table that maps each module's full name (`Instance:GetFullName()`) to whatever it returned. A module that fails to `require` logs a warning with a traceback and is left out.\n\n| Function | Description |\n| --- | --- |\n| `LoadChildren(parent, predicate?)` | Loads the ModuleScripts that are direct children of `parent`. |\n| `LoadDescendants(root, predicate?)` | Loads every ModuleScript descendant of `root`. |\n| `LoadModule(module)` | Loads one ModuleScript, or an array of them. |\n\n`parent`/`root` can be an Instance or an array of Instances. Two loaded sets can be merged with `a + b`. This returns a new table, warns about duplicate names and leaves `a` and `b` unchanged.\n\n### Predicates\n\n| Function | Matches when |\n| --- | --- |\n| `FindName(text)` | the module's name contains `text` |\n| `FindParentName(text)` | the parent's name contains `text` |\n| `MatchName(pattern)` | the module's name matches the Luau string pattern |\n| `MatchParentName(pattern)` | the parent's name matches the Luau string pattern |\n\nA predicate is any `(module: ModuleScript) -> boolean`, so you can write your own.\n\n## Running\n\n| Function | Yields | Description |\n| --- | --- | --- |\n| `SpawnAll(modules, methodName?, callback?)` | No | Calls `methodName` on every module with `task.spawn`. `callback` runs once all of them have finished. |\n| `DeferAll(modules, methodName?, callback?)` | No | Same, but with `task.defer`. |\n| `SpawnPhases(modules, phases, onComplete?)` | No | Runs each phase in order. A phase starts only after every method in the previous phase has finished. |\n| `DeferPhases(modules, phases, onComplete?)` | No | Same, but with `task.defer`. |\n| `SpawnAllAsync` / `DeferAllAsync` / `SpawnPhasesAsync` / `DeferPhasesAsync` | Yes | Same arguments as above, but they yield the calling thread until everything has finished. |\n\nHow a module gets called:\n\n- **Table modules**: `methodName` is called as a method (`module:Init()`). Modules without that method are skipped. So are modules whose field isn't a function; with verbose on, those log a warning.\n- **Function modules**: these are called directly when no `methodName` is given.\n- **Order**: modules start in descending `Priority` (a number field on the module, default `0`), then alphabetically by full name. Each method runs in its own thread, so a yielding method doesn't hold up the others.\n- **Errors**: a method that errors logs a warning with a full traceback and still counts as finished, so callbacks and later phases still run.\n- **Hangs**: if methods are still running after the warn timeout (5 seconds by default), a warning lists them.\n\n## Settings\n\n| Function | Description |\n| --- | --- |\n| `SetVerbose(state)` | Logs each call and each completed phase. `SetDebugInfo` is an alias. |\n| `SetWarnTimeout(seconds)` | Sets how long to wait before warning about methods that haven't finished. `0` turns the warning off. |\n\n## Development\n\n```sh\nrokit install\nlune run tests/run.luau\nstylua --check src tests\nselene src\n```","readmeTruncated":false}