From 5f65a0d674b34352fc7e0e3c289422a775fcca96 Mon Sep 17 00:00:00 2001 From: "viet-anh.n" Date: Wed, 8 Jul 2026 07:57:25 +0000 Subject: [PATCH] [TSC-8] Implement Application State Manager Add state.js ES module with in-memory state (operand1, operand2, selectedOperation, result, error), getters/setters for each property, and a reset() function. Update CLAUDE.md project structure listing. --- CLAUDE.md | 1 + state.js | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 state.js diff --git a/CLAUDE.md b/CLAUDE.md index 15f587d..9c8299c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -8,6 +8,7 @@ Greenfield project. Implementation is driven by the Vexa AI-SDLC pipeline (Jira / ├── index.html # Calculator UI (semantic HTML5) ├── styles.css # Responsive CSS layout and styling +├── state.js # In-memory application state manager (ES module) ├── README.md # Project overview └── CLAUDE.md # This file ``` diff --git a/state.js b/state.js new file mode 100644 index 0000000..8fd298f --- /dev/null +++ b/state.js @@ -0,0 +1,26 @@ +const initialState = { + operand1: null, + operand2: null, + selectedOperation: null, + result: null, + error: null, +}; + +const state = { ...initialState }; + +export function getOperand1() { return state.operand1; } +export function setOperand1(value) { state.operand1 = value; } + +export function getOperand2() { return state.operand2; } +export function setOperand2(value) { state.operand2 = value; } + +export function getSelectedOperation() { return state.selectedOperation; } +export function setSelectedOperation(value) { state.selectedOperation = value; } + +export function getResult() { return state.result; } +export function setResult(value) { state.result = value; } + +export function getError() { return state.error; } +export function setError(value) { state.error = value; } + +export function reset() { Object.assign(state, initialState); }