Calculator Example
This example demonstrates a simple calculator implemented using the Act Framework. It showcases how to define state machines, actions, and events for basic arithmetic operations, and how to compose workflows using event-driven design.
What You'll Learn
- How to define a state machine for a calculator
- How to model actions (key presses) and events (state changes)
- How to use reactions to build workflows
- How to test and run the example
Source Files
- calculator.ts: Calculator state machine and logic
- main.ts: Example usage and entry point
- index.ts: Module entry
How It Works
- The calculator state machine models the left/right operands, operator, and result.
- Actions represent key presses (digits, operators, dot, equals, clear).
- Events are emitted for each key press and drive state transitions.
- The main example demonstrates pressing keys, updating state, and reacting to events.
Usage
See the source files above for implementation details and usage examples.