{"id":"ldgerrits/loader","name":"loader","scope":"ldgerrits","platform":"roblox","description":"A lightweight services loader for the Roblox ecosystem adapted from Axis by Sleitnick","version":"1.0.1","latest":"1.0.1","versions":["1.0.0","1.0.1"],"license":"MIT","licenseRating":"safe","licenseCaveats":["The package archive does not include its license text; the license is declared in its manifest metadata."],"licenseVerified":false,"dependencies":{},"integrity":"0d4c9111a0fcf22ab5b810bf66fd7064f49e5bd4454bff4e21c928ac282abe01","likes":0,"downloads":0,"install":"forest install ldgerrits/loader","url":"https://forest.dev/p/roblox/ldgerrits/loader","files":"https://api.forest.dev/ai/package/roblox/ldgerrits/loader/files","readme":"# Loader\r\n\r\nLoader is a service framework for the Roblox ecosystem.\r\n\r\n## Service Example\r\n\r\nServices are simply tables with a name and a couple lifecycle methods.\r\n\r\n```lua\r\nlocal MyService = {}\r\n\r\nfunction MyService.Init(self: MyService)\r\n\tprint(\"Initialized the service\")\r\nend\r\n\r\nfunction MyService.Start(self: MyService)\r\n\tprint(\"Started\")\r\nend\r\n\r\nreturn MyService\r\n```\r\n\r\nServices must be explicitly added into Loader via `Loader:AddService()`. Once all services are added, `Loader:Start()` will kick off the lifecycle methods of the services.\r\n\r\nA script to bootstrap Loader might look like this:\r\n\r\n```lua\r\nlocal Loader = require(somewhere.Loader)\r\n\r\nfor _, module in ipairs(somewhere.MyServiceModules:GetChildren()) do\r\n\tLoader:AddService(service)\r\nend\r\n\r\nLoader:Start()\r\n```\r\n\r\n## Using multiple services\r\n\r\nBecause services are just tables, it is easy for one service to use another. Simply get a reference to the other service (e.g. requiring its ModuleScript) and then access it after Start has fired. For example:\r\n\r\n```lua\r\nlocal MyService = require(somewhere.MyService) -- Grab the other service\r\n\r\nlocal AnotherService = {}\r\n\r\nfunction AnotherService.Init(self: AnotherService)\r\n\t-- Other services are NOT safe to use here, because there's no guarantee\r\n\t-- that they have all been initialized yet. Wait until Start.\r\nend\r\n\r\nfunction AnotherService.Start(self: AnotherService)\r\n\t-- Other services are safe to use once the Start method fires.\r\n\tMyService:DoSomething()\r\nend\r\n```\r\n\r\n## Memory categories\r\n\r\nBecause Loader services are started from one source, the default memory label within the Developer Console will appear the same for all services. To solve this, Loader will automatically assign a memory category based on the service's name.\r\n\r\nWhen MyService is initialized/started, any memory usage will show up within the MyService label in the Developer Console memory section.\r\n","readmeTruncated":false}