Events and Lifecycle
Lifecycle
const capture = new LookLootCapture(options);
await capture.init();
await capture.start();
await capture.stop();
await capture.dispose();Most apps only need init() during startup. Once initialized, the SDK detects games and starts recording automatically. Recording stops when the detected game exits, when stop() is called, or when dispose() runs.
init() can be called again after startup to refresh or rotate the current device token. Calling start() before init() returns { ok: false, reason: "Call init() first" }.
The SDK installs an Electron before-quit handler by default. If the host app is closed while a recording is active, the handler waits briefly for dispose() so the session can stop and finalize.
State
capture.on("state-change", (state) => {
// "idle" | "active"
});The public SDK intentionally exposes a coarse state model. Use it for UI indicators such as "LookLoot active" or "LookLoot idle".
You can also read the current state directly:
const state = capture.getState();Before a packaged release or smoke test, check local runtime assets without minting a token or starting capture:
const diagnostics = capture.getRuntimeDiagnostics();
if (!diagnostics.ok) {
console.error(diagnostics.checks);
}On Windows, diagnostics verifies the bundled OBS runtime, FFmpeg, the Raw Input helper, and the loopback audio helper.
start() returns Promise<{ ok: true } | { ok: false; reason: string }> so apps can log or surface explicit retry/manual capture requests without catching an exception. stop() and dispose() resolve when teardown work has completed.
Errors
capture.on("error", (error) => {
console.error("[lookloot]", error);
});Handle errors in your app logs or diagnostics. User-facing recovery usually means retrying init() after network or auth issues are resolved.
