← All Learning Paths

State Management Specialist

Tame state at every layer: CRDTs for collaboration, optimistic concurrency for writes, event-carried state for services, and reducers that stay exhaustively typed.

technicalintermediate8 nodes12.92h total

Path overview

状态管理不止前端库,而是从浏览器到数据库的一致性设计。本路径从 CRDT 与乐观并发讲起,覆盖丢失更新、写偏序等经典异常,再落地 Immer、TanStack Query 与类型化状态机,收尾于乐观锁版本列与 Pinia 案例。

State management is a consistency design from browser to database, not a frontend library choice. This path covers CRDTs, optimistic concurrency, lost updates, write skew, and typed state machines.

  1. Stand up "Immer" for a state task, confirm "produce produce(base, recipe): T" holds, and document one failure you triggered.

    Completion criteria: Run a request against "Immer", paste the response, and add one deliberately invalid call with its error.

    Next step: TanStack Query

    ⏱ 1h

  2. Wire "TanStack Query" into a scratch state project, following "useMutation useMutation(options: { mutationFn, onSuccess, onError, ... }): UseMutationResult", and record one working request/response pair.

    Prerequisites: Immer

    Completion criteria: Attach one successful call and one invalid call against "TanStack Query", citing "useMutation useMutation(options: { mutationFn, onSuccess, onError, ... }): UseMutationResult" as the documented surface.

    Next step: React State Management with Zustand

    ⏱ 1h

  3. Adapt "React State Management with Zustand" to a second input and compare the new output with the behavior described in "Usage: const bears = useBearStore((s) => s.bears);".

    Prerequisites: TanStack Query

    Completion criteria: Change one constant in "React State Management with Zustand", rerun, and attach both stdout captures plus a one-line diff explaining what moved.

    Next step: Typed State Machine With Transition Guards

    ⏱ 0.75h

  4. Execute "Typed State Machine With Transition Guards", change one constant, and describe how the output diverges from "Model finite states with typed events, guarded transitions, transition history and clear".

    Prerequisites: React State Management with Zustand

    Completion criteria: Save two runs of "Typed State Machine With Transition Guards" side by side — the original input and one changed value — and annotate the line where the output diverges.

    Next step: Add Optimistic Locking with a Version Column

    ⏱ 0.75h

  5. Run "Existing rows have version 1 and new rows start at 1." from "Add Optimistic Locking with a Version Column" and confirm the documented result "Add a version column with a default of 1 and make it non-null.".

    Prerequisites: Typed State Machine With Transition Guards

    Completion criteria: Show the command for every step of "Add Optimistic Locking with a Version Column" and paste the output proving "Existing rows have version 1 and new rows start at 1."; then note the step where "Add a version column with a default of 1 and make it non-null." appears.

    Next step: Vue 3 + Pinia State Management

    ⏱ 0.5h

  6. Read "Vue 3 + Pinia State Management" as an architecture drill: for each Vue, Pinia, TypeScript, Vite component, state what it owns and what it delegates.

    Prerequisites: Add Optimistic Locking with a Version Column

    Completion criteria: Draw the responsibility table for "Vue 3 + Pinia State Management" and mark one place where your state stack would choose differently.

    Next step: Merge Replicas with Last-Writer-Wins

    ⏱ 1.5h

  7. Turn JSON object: { replicas: [{ id, updates: [{ key, value, clock }] }] } into {merged:{title:B},conflicts:[title]} by completing "Merge Replicas with Last-Writer-Wins" with a reproducible script and a failing-case note.

    Prerequisites: Vue 3 + Pinia State Management

    Completion criteria: Attach the solution file for "State Management Specialist", two passing sample runs, and one failing run whose error matches the contract.

    Next step: Capstone: State Management Specialist

    ⏱ 0.42h

  8. Deliver the "Build an Event-Sourced Account Ledger" blueprint with "Event store" working and "Aggregate replay" recorded as evidence.

    Prerequisites: Vue 3 + Pinia State Management, Merge Replicas with Last-Writer-Wins

    Completion criteria: Deliver "Event store" and paste the test output where the acceptance test passes; include the test name and command.

    Next step: Run the capstone's tests, publish the repository, and demo it to a reviewer.

    ⏱ 4h