Skip to content

Commit 026cf3e

Browse files
add pokemon statechart example
1 parent 8f21a80 commit 026cf3e

18 files changed

Lines changed: 2125 additions & 0 deletions

.github/workflows/ci.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,21 @@ jobs:
2020
cache: pnpm
2121
- run: pnpm install --frozen-lockfile
2222
- run: pnpm check
23+
24+
pokemon-example:
25+
runs-on: ubuntu-latest
26+
defaults:
27+
run:
28+
working-directory: examples/pokemon
29+
steps:
30+
- uses: actions/checkout@v4
31+
- uses: pnpm/action-setup@v4
32+
with:
33+
package_json_file: examples/pokemon/package.json
34+
- uses: actions/setup-node@v4
35+
with:
36+
node-version: 24
37+
cache: pnpm
38+
cache-dependency-path: examples/pokemon/pnpm-lock.yaml
39+
- run: pnpm install --frozen-lockfile
40+
- run: pnpm check

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ pnpm-lock.yaml
55
src
66
test
77
typetest
8+
examples

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,12 @@ The current source reference is branch `sandro/state-charts` in the Effect
103103
repository. Exact dependency pins and the sync check are the proof boundary;
104104
vendoring the rest of Effect is intentionally unnecessary.
105105

106+
## Examples
107+
108+
The [Pokémon statechart example](./examples/pokemon) is a standalone React and
109+
Vite project that installs the published package from npm. Its dependency graph,
110+
lockfile, build, and CI job are isolated from this library package.
111+
106112
## Releases
107113

108114
Add a changeset with `pnpm changeset`. CI validates frozen installation and the

examples/pokemon/.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules/
2+
dist/
3+
.DS_Store

examples/pokemon/README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Pokémon statechart example
2+
3+
A standalone React and Vite application demonstrating parent, child, parallel,
4+
and invoked Effect machines with a live PokéAPI integration.
5+
6+
This project intentionally installs `@typeonce/effect-machine@0.1.0` from npm.
7+
It does not use the repository's local source or a workspace dependency.
8+
9+
```sh
10+
pnpm install --frozen-lockfile
11+
pnpm dev
12+
```
13+
14+
Open the displayed Vite URL and select **Machine**. The application loads a
15+
random team of six Pokémon. You can select a team member, search by Pokémon
16+
name, replace from a search result, or replace a team member with a random
17+
Pokémon.
18+
19+
Run the complete standalone validation with:
20+
21+
```sh
22+
pnpm check
23+
```

examples/pokemon/index.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
6+
<title>Effect Machine Playground</title>
7+
</head>
8+
<body>
9+
<div id="root"></div>
10+
<script type="module" src="/src/main.tsx"></script>
11+
</body>
12+
</html>

examples/pokemon/package.json

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"name": "@typeonce/effect-machine-example-pokemon",
3+
"version": "0.0.0",
4+
"private": true,
5+
"description": "Pokémon statechart example using the published @typeonce/effect-machine package",
6+
"type": "module",
7+
"scripts": {
8+
"dev": "vite",
9+
"build": "tsc --noEmit && vite build",
10+
"preview": "vite preview",
11+
"check": "pnpm build"
12+
},
13+
"dependencies": {
14+
"@effect/atom-react": "4.0.0-beta.102",
15+
"@tanstack/react-router": "1.170.18",
16+
"@typeonce/effect-machine": "0.1.0",
17+
"effect": "4.0.0-beta.102",
18+
"react": "19.2.7",
19+
"react-dom": "19.2.7",
20+
"scheduler": "0.27.0"
21+
},
22+
"devDependencies": {
23+
"@types/react": "19.2.17",
24+
"@types/react-dom": "19.2.2",
25+
"@vitejs/plugin-react": "6.0.4",
26+
"typescript": "6.0.3",
27+
"vite": "8.1.5"
28+
},
29+
"packageManager": "pnpm@10.17.1",
30+
"engines": {
31+
"node": "^20.19.0 || >=22.12.0"
32+
}
33+
}

0 commit comments

Comments
 (0)