{"id":"featherfall-org/quill-dependencies","name":"quill-dependencies","scope":"featherfall-org","platform":"roblox","description":"A dependency management solution for Quill","version":"0.1.0-alpha.3","latest":"0.1.0-alpha.3","versions":["0.1.0-alpha.1","0.1.0-alpha.2","0.1.0-alpha.3"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{"featherfall-org/quill-core":{"version":"^0.1.0-alpha.2","alias":"core"}},"integrity":"7cd27e09cafdad1b4d66192cfe092ba2284f20c9d410e30dbf39ba39a2b037ee","likes":0,"downloads":0,"install":"forest install featherfall-org/quill-dependencies","url":"https://forest.dev/p/roblox/featherfall-org/quill-dependencies","files":"https://api.forest.dev/ai/package/roblox/featherfall-org/quill-dependencies/files","readme":"# Dependencies\r\n\r\nA way to sort your singletons via dependency graphs or singleton priorities.\r\n\r\n## Sorting methods\r\n\r\nThere are currently two sorting methods exposed:\r\n- Topological sorting\r\n- Priority sorting\r\n\r\n### Topological sorting\r\n\r\nTopological sorting relies on singletons defining their dependencies at the top level via `dependencies.use()`, like so:\r\n```luau\r\nlocal dependencies = require(\"@pkg/quill_dependencies\")\r\n\r\nlocal MySingleton = {}\r\nMySingleton.my_dependency = dependencies.use(require(\"@singletons/my_dependency\"))\r\n\r\n...\r\n```\r\nInternally, this function returns a marker that lets the crate know that this property is an uninitialized dependency to resolve later on:\r\n```luau\r\nlocal function use<T>(singleton: T): T\r\n    return { UNINITIALIZED_DEPENDENCY = true, singleton = singleton } :: any\r\nend\r\n```\r\nHowever, we lie to the typechecker about the type of it to allow for a pattern such as this in Luau without overcomplicating the user's code.<br>\r\nThis allows for users to shoot themselves in the foot if they're relying on a marked dependency in any code that can run prior to dependencies being resolved, such as the top level of the module, although it's an acceptable trade-off as it's considered a bad pattern to run any kind of logic before at the very least initialization.\r\n\r\nDependencies defined like this **aren't resolved** if any other sorting method than topological is used.\r\n\r\n### Priority sorting\r\n\r\nPriority sorting relies on the user manually defining priorities for each singleton, and so manually defining their dependency graph.<br>\r\nSingletons with a **higher** priority run before singletons with a lower priority.\r\n```luau\r\nlocal MySingleton = {}\r\nMySingleton.priority = math.huge -- Always runs first\r\n\r\n...\r\n```\r\n\r\n## Usage\r\n\r\nTo use this crate, simply add it to Quill with your preferred sorting method:\r\n```luau\r\nlocal rblx_lifecycles = require(\"@pkg/quill_rblx_lifecycles\")\r\n\r\nQuill:with_mod(rblx_lifecycles.mod(\"topological\" OR \"priority\"))\r\n```\r\n","readmeTruncated":false}