{"id":"molyidev/ignis","name":"ignis","scope":"molyidev","platform":"roblox","description":"Framework library.","version":"0.1.2","latest":"0.1.2","versions":["0.1.0","0.1.1","0.1.2"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"9dadc189b641923b3284686cd5aee69f5ca507fbab46aa4776aa3d6f110fa54f","likes":0,"downloads":0,"install":"forest install molyidev/ignis","url":"https://forest.dev/p/roblox/molyidev/ignis","files":"https://api.forest.dev/ai/package/roblox/molyidev/ignis/files","readme":"# Ignis\n\n> [!WARNING]\n> **Ignis is very early in development.** But it is being used in production, so any bug will be fixed in no time.\n\n## Installation\n\n### Pesde\n\n```bash\npesde add molyidev/ignis\n```\n\n### Wally\n\n```toml\nIgnis = \"molyidev/ignis@^0.1.2\"\n```\n\n## Why use Ignis?\n\n* **Fully Typed:** Designed to work with the new Luau type solver.\n* **Minimal Boilerplate:** Ignis was carefully crafted to be simple and require minimal boilerplate code.\n\n## Usage\n\n### Creating a Controller/Service/Provider/Singleton/you name it\n\n```luau\nlocal Ignis = require(path.to.Ignis)\n\nlocal Example = {}\n\n-- OnInit goes before OnStart and it's sync.\n-- This means that if you do task.wait(1000) in a module with priority 0\n-- then the next module will need to wait for that module to finish initializing\nfunction Example.OnInit()\n    print(\"Initializing...\")\nend\n\n-- OnStart goes after OnInit and it's async.\nfunction Example.OnStart()\n    print(\"Starting...\")\nend\n\n-- This fires when Ignis shuts down.\nfunction Example.OnStop()\n    print(\"Stopping...\")\nend\n\nreturn Ignis.Register(Example)\n```\n\n### Dependency injection\n\nYou can declare dependencies using `Ignis.Dependency` before registering.\nThis will make the module declared as `Dependency` be initialized before the module that was requesting it.\n\n```luau\nlocal Ignis = require(path.to.Ignis)\nlocal OtherSingleton = Ignis.Dependency(require(path.to.OtherSingleton))\n\nlocal ThisSingleton = {}\n\nfunction ThisSingleton.OnStart()\n    OtherSingleton.DoThings()\nend\n\nreturn Ignis.Register(ThisSingleton)\n```\n\nOr you can define all the dependencies in `Ignis.Register`.\n\n```luau\nlocal Ignis = require(path.to.Ignis)\nlocal OtherSingleton = require(path.to.OtherSingleton)\n\nlocal ThisSingleton = {}\n\nfunction ThisSingleton.OnStart()\n    OtherSingleton.DoThings()\nend\n\nreturn Ignis.Register(ThisSingleton, { OtherSingleton })\n```\n\nOr if you're a psycho, you can define your dependencies like this:\n\n```luau\nlocal Ignis = require(path.to.Ignis)\nlocal OtherSingleton = require(path.to.OtherSingleton)\n\nlocal ThisSingleton = {\n    OtherSingleton = OtherSingleton\n}\n\nfunction ThisSingleton.OnStart(self)\n    self.OtherSingleton.DoThings()\n    -- You can also use it like in the other examples\n    -- OtherSingleton.DoThings()\n    -- But if you do it like this then it doesn't make sense to add it to the table.\n    -- That will make you really look like a psycho, but hey, I don't judge, I was the one that kept the feature for you <3.\nend\n\nreturn Ignis.Register(ThisSingleton)\n```\n\n\n### Ignition\n\nStart Ignis in your entry script (server or client).\n\n```luau\nlocal Ignis = require(path.to.Ignis)\n\n-- Load all the modules\nIgnis.LoadDescendants(script.Singletons)\nIgnis.LoadChildren(script.Modding)\n\n-- Then just burn everything\nIgnis.Ignite()\n```\n\n### Lifecycles\n\nIgnis supports custom lifecycle events.\n\n```luau\n-- HeartbeatLifecycle.luau\nlocal Ignis = require(path.to.Ignis)\nlocal RunService = game:GetService(\"RunService\")\n\nlocal onHeartbeat = Ignis.RegisterLifecycle(\"OnHeartbeat\") :: Ignis.Lifecycle<number>\n\nRunService.Heartbeat:Connect(function(dt)\n    onHeartbeat:Fire(dt)\n    -- Or maybe you want to do it sync\n    -- onHeartbeat:FireSync(dt)\nend)\n\nreturn nil\n\n-- SomeSingleton.luau\nlocal Ignis = require(path.to.Ignis)\n\nlocal SomeSingleton = {}\n\nfunction SomeSingleton.OnHeartbeat(dt)\n    print(\"Heartbeat:\", dt)\nend\n\nreturn Ignis.Register(SomeSingleton)\n```\n\n### Components\n\nIgnis creates components by binding them to `CollectionService` tags (or manually). They have `OnSpawn` and `OnDespawn` methods.\n\n```luau\nlocal RunService = game:GetService(\"RunService\")\nlocal Ignis = require(path.to.Ignis)\n\n-- Optional: Define types for strict typing\ntype Coin = {\n    SpinLoop: RBXScriptConnection,\n} & Ignis.Component<BasePart>\n\nlocal Coin = {}\n\n-- Fires when a \"Coin\" tag is added or when the instance streams in\nfunction Coin.OnSpawn(self: Coin)\n    self.SpinLoop = RunService.Heartbeat:Connect(function()\n        self.Instance.Orientation += Vector3.new(0, 1, 0)\n    end)\nend\n\n-- Fires when a \"Coin\" tag is removed, the instance is destroyed, or streams out\nfunction Coin.OnDespawn(self: Coin)\n    if self.SpinLoop then self.SpinLoop:Disconnect() end\nend\n\nreturn Ignis.Component(Coin, {\n    Tag = \"Coin\",\n    BaseClass = \"BasePart\",\n})\n\n```\n\n---\n\nYou can see more examples in `./examples/`.\n\n## Inspiration\n\n**Ignis** takes inspiration from **[Flamework](https://github.com/rbxts-flamework/core)** and **[artwork](https://github.com/ratplier/artwork)**\n","readmeTruncated":false}