Start typing to search packages!
miniknit
By @felixcodestech
Roblox
Mirrored from WallyMiniKnit
A small, predictable Roblox framework: a service/controller loader, a Signal, a Trove and two observers. No dependencies.
Install
[dependencies]
MiniKnit = "felix/miniknit@0.1.0"
Boot
One entry script per side, and nothing else in it.
local MiniKnit = require(ReplicatedStorage.Packages.MiniKnit)
MiniKnit.Start(ServerScriptService.Services)
On the server every ModuleScript under the container whose name ends in Service is loaded, on the client every one ending in Controller. Everything else is ignored. Modules are required, registered, Inited one at a time, then Started in their own thread. Init must not yield and may only resolve dependencies; a Start that errors is warned about and leaves the others running.
API
| Call | Does |
|---|---|
MiniKnit.Start(container) | Boots every service or controller under container. Once only. |
MiniKnit.OnStarted() | Yields until every Init has finished and every Start has been spawned. |
MiniKnit.IsStarted() | Whether the boot has got that far. |
MiniKnit.Services / MiniKnit.Controllers | Read-only registry, keyed by module name. |
MiniKnit.Signal | new, Connect, Once, Fire, Wait, DisconnectAll, Destroy. |
MiniKnit.Trove | new, Add, Connect, Clean, Destroy. |
MiniKnit.ObservePlayers(fn) | Runs fn(player) for everyone here and everyone later, returns stop(). |
MiniKnit.ObserveTag(tag, fn, ancestors?) | Same, for tagged instances under ancestors (default { workspace }). |
Each observed function may return a cleanup function, which runs when the player leaves or the instance loses its tag, is destroyed, streams out or moves out of the allowed ancestors.
A service
-- Requires
local MiniKnit = require(ReplicatedStorage.Packages.MiniKnit)
-- Dependencies
local DataService: typeof(require(script.Parent.DataService))
-- Module
local ShopService = {}
ShopService.ItemPurchased = MiniKnit.Signal.new()
-- Lifecycle
function ShopService.Init()
DataService = MiniKnit.Services.DataService
end
function ShopService.Start()
trove:Connect(ShopService.ItemPurchased, onItemPurchased)
end
return ShopService
test/Scenarios/Boot/Example holds the full version, with every section a service may have, and is the reference to copy from.
Tests
test.project.json builds a place that runs every scenario in a single playtest: the ones under Scenarios/Fail each make the boot fail in one specific way, the ones under Scenarios/Boot boot together. Each check prints a [Test] PASS or [Test] FAIL line, and each side prints a summary.
rojo serve test.project.json
Package Details
Install command (Click to copy)
Version
0.2.0
License
MIT
Safe for commercial use
Automated license review — not legal advice.
