BACK
Use casesAutosave — saving the form in the background
Use cases · 02

Autosave — saving the form in the background

Pattern

Autosave turns a form into a stream of changes. The user types — we accumulate the deltas, wait for a pause, and send the latest version.

What we solve

  • Redundant requests. We don't go to the network on every keystroke.
  • Race condition. If new changes arrive, the old save can be cancelled — the final version matters more.
  • A clear status. The UI knows three states: idle / saving / saved.

The operators and their roles

  • debounceTime — wait for a pause in editing.
  • switchMap — new changes cancel an unfinished save.
  • tap — update the status "saving…" / "saved".

What we achieve

Minimal requests, the latest version always saved, and the status indicator changes automatically.

script.ts // TypeScript
CONSOLE · Console output
Hit Run to see the result...