Command Palette

Search for a command to run...

Hectal
Phase 27: Capstone: Build a Complete App
React · Exercise 5 of 6 PreviousNext
Advanced

Milestone 5: optimistic moves with rollback

The board loads from a fake API that takes 300 ms. Moving a card waits for the server, and failures are ignored. Make moveTask optimistic.

Move the card at once, then call api.moveTask. If it throws, move only that card back to where it was and put a message containing Could not move into alertStore (it shows in a role="alert" banner).

Tick #server-down to make every request fail. The app opens on /?priority=high, so you see Build static components (Doing) and Plan the board (Done).

What Check tests

  1. The board loads from the fake API
  2. A move shows at once, before the server answers
  3. After the server agrees, the card stays and there is no error
  4. When the server fails, the card moves, then comes back with a message

Stuck? One hint at a time

The solution unlocks after your first Check. Try first: that is where the learning happens.

Runs in your browser. Your code is saved here.

Your page

Press Run to see the page.

Console

Nothing logged yet.