@typeonce/effect-machine 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/docs/effect-atom-react.md +35 -5
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -34,10 +34,10 @@ Cluster and are exposed only through explicit integration boundaries.
|
|
|
34
34
|
## Install
|
|
35
35
|
|
|
36
36
|
```sh
|
|
37
|
-
pnpm add @typeonce/effect-machine effect@4.0.
|
|
37
|
+
pnpm add @typeonce/effect-machine effect@4.0.5
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
`effect` is a peer dependency requiring stable `^4.0.
|
|
40
|
+
`effect` is a peer dependency requiring stable `^4.0.5`. Keep any installed
|
|
41
41
|
`@effect/*` packages on the same version as `effect`.
|
|
42
42
|
|
|
43
43
|
Development and benchmarks use exact versions. CI checks both the pinned
|
|
@@ -220,11 +220,41 @@ function AuthScreen() {
|
|
|
220
220
|
}
|
|
221
221
|
```
|
|
222
222
|
|
|
223
|
-
That component rerenders for every result change.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
a
|
|
223
|
+
That component rerenders for every result change. Prefer typed path selectors
|
|
224
|
+
for state-owned UI.
|
|
225
|
+
|
|
226
|
+
Selection and equality belong to atoms, not to React hooks. To subscribe to
|
|
227
|
+
part of a selected value, derive an atom from the path selector and give it the
|
|
228
|
+
equality that defines a meaningful change. Declare the derivation once with
|
|
229
|
+
`Atom.family`, keyed by the machine atom, so every render reuses the same atom:
|
|
230
|
+
|
|
231
|
+
```tsx
|
|
232
|
+
import { useAtomSuspense } from "@effect/atom-react"
|
|
233
|
+
import { Equal, Option } from "effect"
|
|
234
|
+
import { Atom } from "effect/reactivity"
|
|
235
|
+
|
|
236
|
+
type AuthMachineAtom = ReturnType<typeof useAuthMachine>
|
|
237
|
+
|
|
238
|
+
const editingEmail = Atom.family((machine: AuthMachineAtom) =>
|
|
239
|
+
Atom.mapResult(
|
|
240
|
+
AtomMachine.select(machine, "Editing"),
|
|
241
|
+
Option.map(({ email }) => email)
|
|
242
|
+
).pipe(Atom.withEquality(Equal.equals))
|
|
243
|
+
)
|
|
244
|
+
|
|
245
|
+
function EmailField() {
|
|
246
|
+
const machine = useAuthMachine()
|
|
247
|
+
const email = useAtomSuspense(editingEmail(machine)).value
|
|
248
|
+
|
|
249
|
+
return Option.match(email, {
|
|
250
|
+
onNone: () => null,
|
|
251
|
+
onSome: (email) => <input value={email} />
|
|
252
|
+
})
|
|
253
|
+
}
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
The component rerenders only when the projected email changes, not when other
|
|
257
|
+
`Editing` fields change. Do not create a fresh derived atom on every render.
|
|
228
258
|
|
|
229
259
|
## Share a keyed machine outside one React owner
|
|
230
260
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@typeonce/effect-machine",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.41.0",
|
|
4
4
|
"description": "Schema-first state machines and statecharts for Effect",
|
|
5
5
|
"author": "Sandro Maglione",
|
|
6
6
|
"repository": {
|
|
@@ -46,12 +46,12 @@
|
|
|
46
46
|
"provenance": true
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"effect": "^4.0.
|
|
49
|
+
"effect": "^4.0.5"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@effect/vitest": "4.0.
|
|
52
|
+
"@effect/vitest": "4.0.5",
|
|
53
53
|
"@types/node": "25.7.0",
|
|
54
|
-
"effect": "4.0.
|
|
54
|
+
"effect": "4.0.5",
|
|
55
55
|
"tinybench": "2.9.0",
|
|
56
56
|
"tstyche": "7.2.1",
|
|
57
57
|
"typescript": "6.0.3",
|