A tutorial for using signals in Temporal to coordinate an event-driven UI for a durable, long-lived game of life.
The game of life is composed of some very simple, deterministic rules:
- Any live cell with fewer than two live neighbours dies, as if by underpopulation.
- Any live cell with two or three live neighbours lives on to the next generation.
- Any live cell with more than three live neighbours dies, as if by overpopulation.
- Any dead cell with exactly three live neighbours becomes a live cell, as if by reproduction.
Warning
This is NOT a good production use case for Temporal. We are simply exploring how Temporal can be used for durable, long-running jobs!
Implement the splatter method, which allows a visitor to click and make a random amount of cells appear.
Implement the toggle signal, allowing the user to pause and unpase.
- Create new selector callbacks on the main selector for each signal (splatter and toggle)
- Implement the splatter activity for the splatter signal to your liking
- Test durability (nuke the backend + refresh the frontend)
-
Download go. Follow the suggested instructions or use your packaege manager like below
# macOS brew install go # Windows scoop install go
-
Download Temporal. Follow the suggested instructions or use your package manager like below
# macOS brew install temporal # Windows scoop install temporal
-
Optionally, download Node and pnpm for the frontend. Follow the suggested instructions or use your packaege manager like below
# macOS brew install node npm install -g pnpm # Windows scoop install nodejs npm install -g pnpm
-
Run Temporal on port 7233 (the port can be changed in main.go). The UI will be available at http://localhost:8233
temporal server start-dev
-
Run the Go backend on port 8080
cd backend go run .
-
Optionally, run the React frontend on port 5173 (default for Vite): https://localhost:5173
cd frontend pnpm install pnpm run dev -
If you opt to not use the frontend, Decrease the board size to 40 X 40 and print to the terminal