You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: readme.md
+94Lines changed: 94 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,19 @@ npm add yieldmachine
20
20
21
21
Starts a machine, transitioning to its initially returned state.
22
22
23
+
```ts
24
+
function Switch() {
25
+
function* Off() {
26
+
yieldon("FLICK", On);
27
+
}
28
+
function* On() {
29
+
yieldon("FLICK", Off);
30
+
}
31
+
32
+
returnOff;
33
+
}
34
+
```
35
+
23
36
### `.current: string | Record<string, unknown>`
24
37
25
38
The current state of the machine. If machines were nested then an object is returned with the parent machine as the key, and its current state as the value.
@@ -47,14 +60,95 @@ Cleans up the machine.
47
60
48
61
Transitions to the target state when the given event occurs.
Runs the provided function when this state is entered. If the function returns a promise, its value is made available in the `.results` property of the machine, keyed by the name of this passed function.
0 commit comments