다른 항목으로 이동할 때
Identity Boundary And Reset
Prevent temporary state and pending outcomes from leaking across entity or account changes.
이 자료로 구현하기
원문 주소와 버전이 포함된 요청문입니다. 복사한 뒤 만들 화면과 요구사항을 채워 에이전트에게 전달하세요.
FROM PRINCIPLE TO PRACTICE
이 원리로 만든 예제 1
예제를 열어 직접 조작하고, 관찰한 동작을 이 문서의 원리와 비교해 보세요.
항목 전환과 오래된 응답Identity boundary
- 항목 ID와 세대가 함께 일치해야 적용
A에서 만든 요청을 B를 거쳐 돌아온 A에 도착시켜 보세요. 이전 세대의 응답은 거부되고 새 초안은 유지됩니다.
- 항목 ID와 세대가 함께 일치해야 적용
Repository Boundary
Prevent temporary state and pending outcomes from leaking across entity or account changes. This pattern belongs to Design Engineering and adds no Layout CSS or shared store implementation.
Reusable Method
Use when a mounted editor is reused for a different document, tenant, or account. Preserve drafts per identity only when that is an explicit product feature.
State Model And Ownership
The screen owner stores identity and generation. Entering a new identity clears identity-local values and invalidates previous operations. Generation matters even when the user goes A → B → A.
Transitions
| Event and precondition | Next state | Effect or invariant |
|---|---|---|
| Enter identity | Fresh generation and local state | Invalidate earlier callbacks |
| Matching-generation completion | Apply within current identity | Accept only live work |
| Old-generation completion | Unchanged | Reject even if the entity ID matches again |
Minimal Executable Example
Run this standalone JavaScript block with Node.js 22 or newer, or run all pattern examples from a repository checkout with bun run test:state-management. The assertions exercise the local model, not a browser or backend.
import assert from "node:assert/strict";
let generation = 0, identity = null, draft = "";
function enter(id) { identity = id; generation++; draft = ""; }
function ticket() { return { identity, generation }; }
function receive(t, value) {
if (t.identity === identity && t.generation === generation) draft = value;
}
enter("A");
const oldA = ticket();
enter("B");
enter("A");
receive(oldA, "stale A");
assert.equal(draft, "");
receive(ticket(), "current A");
assert.equal(draft, "current A");What Breaks If Removed
Checking entity ID alone accepts the old A request after returning from B to A. Resetting the draft without invalidating requests lets a late response repopulate it.
Composition And Substitution
Combine latest request wins within each generation and versioned restore for explicit per-identity persistence. Apply unsaved navigation before abandoning dirty work.
Opinionated Guidance
Define the identity tuple, including tenant when needed. Clear sensitive caches at the session boundary rather than relying solely on component unmount.
Platform-Specific Guidance
Framework keys can recreate components, but external listeners, caches, timers, and requests still need explicit cleanup. Router reuse may preserve component instances.
Unsupported Absolutes
A UI reset is not an authorization or secure data-erasure mechanism.
Verification Contract
- Switch A → B while a read is pending; no A result appears in B.
- Switch A → B → A; reject the first generation's callback.
- Inspect focus, local errors, draft, and subscriptions after switching.
Record actual outcomes separately using the verification matrix.
Source, License, And Attribution
Locally authored synthesis and examples. No upstream implementation is copied. These experimental contracts describe consumer-owned behavior; review when a failure, ownership change, or platform change invalidates an assumption.
IA Navigation
Parent: State Management. Next: Continue the state management route.


