{"id":"emdomanus/hook","name":"hook","scope":"emdomanus","platform":"roblox","description":"A tiny low-overhead id-based subscriber list for Roblox.","version":"0.1.0","latest":"0.1.0","versions":["0.1.0"],"license":"MIT","licenseRating":"safe","licenseCaveats":[],"licenseVerified":true,"dependencies":{},"integrity":"60caf3561c62aab0e5b04f33d6ff1dcaf57df4fb53137615c29ed46feea87f88","likes":0,"downloads":0,"install":"forest install emdomanus/hook","url":"https://forest.dev/p/roblox/emdomanus/hook","files":"https://api.forest.dev/ai/package/roblox/emdomanus/hook/files","readme":"# Hook\n\nHook is a tiny id-based subscriber list for Roblox Luau.\n\nIt is built for hot callback lists where returned unbind closures and hash-table callback sets are more overhead than you want.\n\n```luau\nlocal Hook = require(path.to.hook)\n\nlocal stepped = Hook.new<number>()\n\nlocal id = stepped:add(function(dt)\n\tprint(dt)\nend)\n\nstepped:fire(1 / 60)\nstepped:remove(id)\n```\n\n## API\n\n- `Hook.new()` creates a subscriber list.\n- `hook:add(callback)` returns a numeric id.\n- `hook:remove(id)` removes a callback and returns whether it existed.\n- `hook:fire(...)` calls the active callbacks.\n- `hook:clear()` removes every callback.\n- `hook:size()` returns the active callback count.\n- `hook:has(id)` returns whether an id is active.\n- `hook:deconstruct()` clears the hook.\n\nRemoval outside of `fire` is O(1). Removal during `fire` is deferred and compacted once the current dispatch finishes, so callbacks can safely unhook themselves or others while the hook is firing.\n","readmeTruncated":false}