Skip to content

Auto Save

Save user input when the session becomes idle or the page is hidden.

Architecture

mermaid
flowchart TD
  Input[User Input] --> App[Application State]
  App --> BL[Browser Lifecycle]
  BL -->|page:hidden / session:idle| Save[Persist Draft]

Implementation

ts
lifecycle.on("page:hidden", () => saveDraft());
lifecycle.on("session:idle", () => saveDraft());

Best practices

Debounce saves and avoid writing on every keystroke.

Playground

Idle Playground · Visibility Playground

JOC is a JayOnCode monorepo of @jayoncode/* packages. Docs sync from source via TypeDoc and sync scripts.