cinderRuntime
require("@me::hazard.cinderRuntime")
Where a component parks the state that has to outlive its own hot reload.
A reloaded component gets fresh locals. The unsubscribe closures it took from
cinder.on in its previous incarnation are gone, while the handlers themselves
are still on the bus — so every reload leaves another live copy of the same
handler behind, and one event fires it several times. Modules survive component
reloads, so this one holds the unsubscribes across that boundary.
local runtime = require("@me::hazard.cinderRuntime")
local SUBS = "MyComponent"
function awake()
runtime.claim(SUBS) -- drop the last incarnation's
runtime.keep(SUBS, cinder.on("run.start", start)) -- park this one's
end
function onDestroy()
runtime.release(SUBS)
end
Each key is independent, so claiming one slot never touches another
component's — or another slice's — subscriptions. runtime.count(key) reports
how many are parked, which is the quickest way to see whether a reload doubled
something.
Deliberately tiny and stable. Editing this file is what reloads it, which is the one thing that would defeat it.
Scoped to this part · feeds back into the world's score.