💡이건 그냥 상태 머신 아닌가? 그렇다! … “불리언 수프”에 기대는 컴포넌트도 마찬가지다. 선택은 상태 머신을 만드느냐 마느냐가 아니라, 암시적으로 만드느냐 명시적으로 만드느냐다.
stateDiagram-v2
[*] --> Mounting
Mounting --> AwaitingEmailInput
Mounting --> AwaitingCodeInput
AwaitingEmailInput --> SubmittingEmail
SubmittingEmail --> AwaitingCodeInput
SubmittingEmail --> AwaitingEmailInput
AwaitingCodeInput --> SubmittingCode
SubmittingCode --> Success
SubmittingCode --> AwaitingCodeInput
Success --> [*]
No, disabling a button is not app logic. - DEV Community
- "idle" 아무 것도 아직 일어나지 않았다.
- "loading" 진행중
- "success" 성공적
- "failure" 오류가 발생했음
In information technology and computer science, a system is described as stateful if it is designed to remember preceding events or user interactions. The remembered information is called the state of the system.
idle·loading·success·failure— 버튼 비활성화는 앱 로직이 아니다- 상태 머신 — 스테이트차트·UML 표기·TypeStates
- Signal — 읽은 곳만 다시 계산하는 반응성
- State Reducer 패턴 — reducer 를 넘겨 훅 동작을 바꾼다
- Redux 스타일 store 직접 구현
useGenerator— 핸들러를 async generator 로 받아 yield 마다 상태를 바꾼다