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
+11-9Lines changed: 11 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -79,15 +79,15 @@ function Switch() {
79
79
}
80
80
```
81
81
82
-
Now our machine is ready to be run. We pass our `Switch` to the `start` function we import from `yieldmachine`, and it will run an instance of our machine. And as we send it `"FLICK"` message, you’ll see the `current` state of our machine instance change.
82
+
Now our machine is ready to be run. We pass our `Switch` to the `start` function we import from `yieldmachine`, and it will run an instance of our machine. And as we send it `"FLICK"` message, you’ll see the `value` of our machine instance change.
83
83
84
84
```ts
85
85
const machine =start(Switch);
86
-
machine.current; // "Off"
86
+
machine.value; //{ state: "Off", change: 0 }
87
87
machine.next("FLICK");
88
-
machine.current; // "On"
89
-
machine.next("TOGGLE");
90
-
machine.current; // "Off"
88
+
machine.value; //{ state: "On", change: 1 }
89
+
machine.next("FLICK");
90
+
machine.value; //{ state: "Off", change: 2 }
91
91
```
92
92
93
93
## Benefits of Generator Functions
@@ -106,17 +106,19 @@ machine.current; // "Off"
106
106
107
107
Starts a machine, transitioning to its initially returned state.
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.
112
114
113
-
### `.changeCount: number`
115
+
####`.value.change: number`
114
116
115
117
The number of times this machine has transitioned. Useful for consumers updating only when changes have been made.
116
118
117
-
###`.results: Promise<unknown>`
119
+
#### `.value.results: Promise<unknown>`
118
120
119
-
The result of any `entry()` or `exit()` messages.
121
+
The result of calling functions passed to `entry()` or `exit()`.
0 commit comments